Chris Betti
Chris Betti

Reputation: 2923

Listing all Versions of an Artifact via Command Line

Including all versions installed to ~/.m2, and deployed to maven or an artifact repository like artifactory.

For example, if I type something like this make believe command:

mvn ver:show-all -DartifactId=myProject -DallowSnapshots=true

I hope to see some output listing available versions:

myProject ->
  0.9
  1.0.1
  1.1-branchA-SNAPSHOT
  1.1-branchB-SNAPSHOT
  1.1-branchC-SNAPSHOT

Is there a maven plugin which does this today?

Upvotes: 21

Views: 6636

Answers (1)

madhead
madhead

Reputation: 33392

What you can do is look at Maven Repository Metadata Model. It's basically and XML file that you can download and parse. For example, to know all the versions of Google Guice available in Maven Central download repository metadata, available at https://repo1.maven.org/maven2/com/google/inject/guice/maven-metadata.xml and look at its content:

<metadata>
  <groupId>com.google.inject</groupId>
  <artifactId>guice</artifactId>
  <versioning>
    <latest>4.2.2</latest>
    <release>4.2.2</release>
    <versions>
      <version>1.0</version>
      <version>2.0</version>
      <version>2.0-no_aop</version>
      <version>3.0-rc2</version>
      <version>3.0-rc3</version>
      <version>3.0</version>
      <version>4.0-beta</version>
      <version>4.0-beta4</version>
      <version>4.0-beta5</version>
      <version>4.0</version>
      <version>4.1.0</version>
      <version>4.2.0</version>
      <version>4.2.1</version>
      <version>4.2.2</version>
    </versions>
    <lastUpdated>20181029173633</lastUpdated>
  </versioning>
</metadata>

You'll see all the versions!

Though, it's not a 100% complete solution:

  • There may be newer (other) version(s) in other repositories. E.g. if one syncs JARs from Bintray to Maven Central Bintray can contain the JARs not available in Central. Though, they seem to be the same for Guice.
  • There may be no maven-metadata.xml. E.g. if you're using JitPack or repos hosted on S3.

Upvotes: 8

Related Questions