Thursday, May 2, 2024
HomeJavaMaven Central Search Retrieves Dependency Coordinates from Maven Central

Maven Central Search Retrieves Dependency Coordinates from Maven Central


Maven Central Search (mcs) is a command line software to retrieve dependency coordinates from Maven Central. The software makes use of Picocli for the command line interface and GraalVM to compile executable native pictures for macOS, Linux and Home windows.

The wildcard search choice shows all artifacts from Maven Central containing the offered argument of their identify. The next instance retrieves all artifacts, containing spring-boot-starter, together with the date of the final launch:


mcs search spring-boot-starter
Trying to find spring-boot-starter...
Discovered 4626 outcomes (displaying 20)

  Coordinates                            Final up to date
  ===========                            ============
  org.teasoft:bee-spring-boot-starter    13 Sep 2022 at 12:40 (CEST)
  com.infilos:relax-spring-boot-starter  13 Jun 2022 at 16:27 (CEST)
  io.sreworks:tesla-spring-boot-starter  06 Jun 2022 at 10:01 (CEST)
  com.seepine:spring-boot-starter-parent 05 Jun 2022 at 14:50 (CEST)
  io.nats:nats-spring-boot-starter       25 Might 2022 at 14:36 (CEST)
  …

The coordinate search retrieves all artifacts for the offered coordinate:


mcs search org.springframework.boot:spring-boot-starter
Trying to find org.springframework.boot:spring-boot-starter...
Discovered 170 outcomes (displaying 20)

  Coordinates                                       	Final up to date
  ===========                                       	============
  org.springframework.boot:spring-boot-starter:2.7.5	20 Oct 2022 at 15:26 (CEST)
  org.springframework.boot:spring-boot-starter:2.6.13 20 Oct 2022 at 11:56 (CEST)
  org.springframework.boot:spring-boot-starter:2.7.4	 22 Sep 2022 at 13:44 (CEST)
  org.springframework.boot:spring-boot-starter:2.6.12 22 Sep 2022 at 11:32 (CEST)
  org.springframework.boot:spring-boot-starter:2.7.3	 18 Aug 2022 at 08:30 (CEST)
  …

The pom.xml configuration is proven as a substitute of a desk every time Maven Central returns precisely one end result:


mcs search org.springframework.boot:spring-boot-starter:2.7.5
Trying to find org.springframework.boot:spring-boot-starter:2.7.5...

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    	  <model>2.7.5</model>
    </dependency>

All mcs instructions help the -l <quantity> argument to specify the utmost variety of outcomes:


mcs search -l 3 org.springframework.boot:spring-boot-starter 
Trying to find org.springframework.boot:spring-boot-starter...
Discovered 170 outcomes (displaying 3)

  Coordinates                                       	Final up to date
  ===========                                       	============
  org.springframework.boot:spring-boot-starter:2.7.5	20 Oct 2022 at 15:26 (CEST)
  org.springframework.boot:spring-boot-starter:2.6.13 20 Oct 2022 at 11:56 (CEST)
  org.springframework.boot:spring-boot-starter:2.7.4	 22 Sep 2022 at 13:44 (CEST)

Retrieving artifacts containing a selected class identify is feasible with class identify search:


mcs class-search Joiners
Trying to find artifacts containing Joiners...
Discovered 232 outcomes (displaying 20)

  Coordinates                            	       Final up to date
  ===========                            	       ============
  io.github.light0x00:to-be-graceful:0.0.2   23 Aug 2022 at 16:24 (CEST)
  io.github.light0x00:to-be-graceful:0.0.1   20 Aug 2022 at 12:28 (CEST)
  me.hao0:diablo-common:1.0.2               10 Oct 2016 at 15:57 (CEST)
  …

Optionally the -f flag could also be used to specify a completely categorized class identify:


mcs class-search -f org.optaplanner.core.api.rating.stream.Joiners
Trying to find artifacts containing org.optaplanner.core.api.rating.stream.Joiners...
Discovered 106 outcomes (displaying 20)

  Coordinates                                        Final up to date
  ===========                                        ============
  org.optaplanner:optaplanner-core:7.65.0.Ultimate      03 Feb 2022 at 19:54 (CET)
  org.optaplanner:optaplanner-core-impl:8.29.0.Ultimate 14 Oct 2022 at 14:17 (CEST)
  org.optaplanner:optaplanner-core-impl:8.28.0.Ultimate 26 Sep 2022 at 12:13 (CEST)
  …

The command line interplay is constructed with Picocli, a one file Java framework which makes it simpler to create command line functions. Picocli helps TAB completion, choice parameters and subcommands. Purposes utilizing Picocli could also be compiled forward of time to a GraalVM native picture which leads to a single executable file.

mcs could also be put in on macOS, Linux and Home windows with the Homebrew, Snap, SDKMAN! and Chocolatey bundle managers. The launch course of of mcs is automated utilizing JReleaser.

InfoQ spoke to Maarten Mulders, IT Architect at Data Assist, Java Champion and the creator of mcs.

InfoQ: What was the inspiration to create the venture?

Mulders: I learn an article within the NLJUG “Java Journal” by Julien Lengrand-Lambert about creating CLI’s with Kotlin and PicoCLI. It made me curious. Wouldn’t it actually be really easy? My fingers the place itching, however I did not actually have a aim but. And simply doing once more what was written out within the article appeared boring to me. On the similar time, I discovered myself usually switching from my editor or command line to an internet browser, solely to go to search.maven.org for trying up actual Maven coordinates. Voilà, my use case was there. As I did not know a lot Kotlin again then, I made a decision to go along with Java 17.

InfoQ: Which is your favourite function of mcs?

Mulders: That will be the truth that when you have specified the precise coordinates of an artifact, mcs will output the pom.xml snippet for you. I am nonetheless considering if I may present the snippet for extra conditions. As an illustration, whenever you specify a groupId + artifactId along with a brand new command line flag comparable to --latest. However I have not fairly made up my thoughts about that concept.

InfoQ: Are you able to already inform us one thing about upcoming options?

Mulders: I’ve already had (and rejected!) so many concepts! However one of many extra attention-grabbing concepts that was proposed, fairly some time in the past by Benjamin Marwell, is to embody a vulnerability rating. I nonetheless need to dive a bit into the small print. Most particularly, there appears to be an API offered by Sonatype for this objective, however you possibly can’t invoke it too usually until you create an account.

InfoQ: What do you want most about sustaining the venture?

Mulders: I just like the interactions with customers of the software, individuals telling me how helpful it’s to them. Additionally, I’ve had fairly a number of attention-grabbing conversations, each on-line and offline, about new options and whether or not/how they would slot in the software. I ought to undoubtedly embody the truth that releasing the venture is known as a matter of two mouse clicks and a little bit of endurance. A couple of minutes later, the brand new model shall be out, revealed by main distribution channels like SDKMAN!, Homebrew and Chocolatey. That deserves a shout-out to Andres Almiray – he gave me numerous assist in organising JReleaser in order that creating a brand new launch is definitely a enjoyable factor to do, slightly than a “fingers crossed” one.

Initially launched in December 2021, mcs 0.2.3 is the newest model. Extra details about mcs could be discovered within the introduction weblog.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments