Maven Central Search (mcs) is a command line tool to retrieve dependency coordinates from Maven Central. The tool uses Picocli for the command line interface and GraalVM to compile executable native images for macOS, Linux and Windows.
The wildcard search option displays all artifacts from Maven Central containing the provided argument in their name. The following example retrieves all artifacts, containing spring-boot-starter, including the date of the last release:
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)
…
The pom.xml
configuration is shown instead of a table 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...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.5</version>
</dependency>
All mcs
commands support the -l <number>
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)
Retrieving artifacts containing a specific class name is possible with class name search:
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)
…
Optionally, the -f
flag may 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 one-file Java framework that makes it easier to create command-line applications. Picocli supports TAB completion, option parameters, and subcommands. Applications using Picocli may be compiled ahead of time to a GraalVM native image which results in a single executable file.
mcs
may be installed on macOS, Linux, and Windows with the Homebrew, Snap, SDKMAN!, and Chocolatey package managers. The release process of mcs
is automated using JReleaser.
InfoQ spoke to Maarten Mulders, IT Architect at Info Support, Java Champion and the creator of mcs
.
InfoQ: What was the inspiration for creating the project?
Mararten Mulders: I read an article in the NLJUG "Java Magazine" by Julien Lengrand-Lambert about creating CLI's with Kotlin and PicoCLI. It made me curious. Would it really be so easy? My fingers where itching, but I didn't really have a goal yet. And just doing again what was written out in the article seemed boring to me. At the same time, I found myself often switching from my editor or command line to a web browser, only to visit search.maven.org for looking up exact Maven coordinates. Voilà, my use case was there. As I didn't know much Kotlin back then, I decided to go with Java 17.
InfoQ: Which is your favorite feature of mcs?
Mulders: That would be the fact that if you have specified the exact coordinates of an artifact, mcs will output the
pom.xml
snippet for you. I'm still contemplating if I could provide the snippet for more situations. For instance, when you specify agroupId
+artifactId
together with a new command line flag such as--latest
. But I haven't quite made up my mind about that idea.
InfoQ: Can you already tell us something about upcoming features?
Mulders: I've already had (and rejected!) so many ideas! But one of the more interesting ideas that was proposed, quite a while ago by Benjamin Marwell, is to include a vulnerability score. I still have to dive a bit into the details. Most 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 like most about maintaining the project?
Mulders: I like the interactions with users of the tool, people telling me how useful it is to them. Also, I've had quite a few interesting conversations, both online and offline, about new features and whether/how they would fit in the tool. I should definitely include the fact that releasing the project is really a matter of two mouse clicks and a bit of patience. A few minutes later, the new version will be out, published through major distribution channels like SDKMAN!, Homebrew and Chocolatey. That deserves a shout-out to Andres Almiray - he gave me a lot of help in setting up JReleaser so that creating a new release is actually a fun thing to do, rather than a "fingers crossed" one.
Initially released in December 2021, mcs
0.2.3 is the latest version. More information about mcs
can be found in the introduction blog.