Maven Central Search retrieves dependency coordinates from Maven Central
Maven Central Search (mcs) is a command line tool for retrieving dependency coordinates from Maven Central. The tool uses Picocli for the command line interface and GraalVM to compile native executable images for macOS, Linux and Windows.
The generic search option displays all Maven Central artifacts that contain the provided argument in their name. The following example retrieves all artifacts, containing spring-boot-starterincluding the date of the latest version:
mcs search spring-boot-starter Searching for spring-boot-starter... Found 4626 results (showing 20) Coordinates Last updated =========== ============ 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 May 2022 at 14:36 (CEST) …
The coordinate search retrieves all artifacts for the provided coordinate:
mcs search org.springframework.boot:spring-boot-starter Searching for org.springframework.boot:spring-boot-starter... Found 170 results (showing 20) Coordinates Last updated =========== ============ 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) …
pom.xml configuration is displayed instead of an array whenever Maven Central returns exactly one result:
mcs search org.springframework.boot:spring-boot-starter:2.7.5 Searching for org.springframework.boot:spring-boot-starter:2.7.5...
org.springframework.boot spring-boot-starter 2.7.5
mcs commands support
-l argument to specify the maximum number of results:
mcs search -l 3 org.springframework.boot:spring-boot-starter Searching for org.springframework.boot:spring-boot-starter... Found 170 results (showing 3) Coordinates Last updated =========== ============ 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)
Searching for artifacts containing a specific class name is possible with search by class name:
mcs class-search Joiners Searching for artifacts containing Joiners... Found 232 results (showing 20) Coordinates Last updated =========== ============ 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) …
-f flag can be used to specify a fully classified class name:
mcs class-search -f org.optaplanner.core.api.score.stream.Joiners Searching for artifacts containing org.optaplanner.core.api.score.stream.Joiners... Found 106 results (showing 20) Coordinates Last updated =========== ============ org.optaplanner:optaplanner-core:7.65.0.Final 03 Feb 2022 at 19:54 (CET) org.optaplanner:optaplanner-core-impl:8.29.0.Final 14 Oct 2022 at 14:17 (CEST) org.optaplanner:optaplanner-core-impl:8.28.0.Final 26 Sep 2022 at 12:13 (CEST) …
The command line interaction is built with Picocli, a single-file Java framework that makes it easy to build command-line applications. Picocli supports TAB completion, option parameters and subcommands. Applications using Picocli can be pre-compiled into a native GraalVM image, resulting in a single executable file.
InfoQ spoke to Martin MuldersIT architect at Info Support, Java champion and creator of
InfoQ: What was the inspiration for creating the project?
Muller: I read an article in Julien Lengrand-Lambert’s NLJUG “Java Magazine” about creating CLI with Kotlin and PicoCLI. It made me curious. Would it really be that easy? My fingers were itching, but I didn’t really have a goal yet. And redoing what was written in the article seemed boring to me. At the same time, I often found myself switching from my editor or command line to a web browser, to visit search.maven.org to find the exact Maven coordinates. There you go, my use case was there. Since I didn’t know much about Kotlin at the time, I decided to go with Java 17.
InfoQ: What is your favorite mcs feature?
Muller: It would be the fact that if you specified the exact coordinates of an artifact, mcs will display the
pom.xmlextract for you. I’m still considering if I could provide the snippet for more situations. For example, when you specify a
artifactIdwith a new command line flag such as
--latest. But I haven’t quite made up my mind about this idea.
InfoQ: Can you already tell us about the upcoming features?
Muller: I’ve already had (and rejected!) so many ideas! But one of the most interesting ideas that was proposed quite some time ago by Benjamin Marwell is to include a vulnerability score. I still have to dive a bit into the details. Specifically, there seems to be an API provided by Sonatype for this purpose, but you can’t invoke it too often unless you create an account.
InfoQ: What do you enjoy most about keeping the project going?
Muller: I like the interactions with the users of the tool, people tell me how useful it is to them. Also, I had quite a few interesting conversations, both online and offline, about new features and if/how they would fit into the tool. I should definitely include the fact that publishing the project is really a matter of two mouse clicks and a little patience. A few minutes later, the new version will be released, released through major distribution channels like SDKMAN!, Homebrew, and Chocolatey. This deserves credit to Andres Almiray – he helped me a lot in configuring JReleaser so that creating a new release is actually a fun thing to do, rather than a “fingers crossed”.