20

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?

Chris Betti
  • 2,721
  • 2
  • 27
  • 36
  • I don't think there is a Maven plugin to do that. This might be of interest though: http://stackoverflow.com/q/1374064/1743880 – Tunaki Nov 20 '15 at 21:06
  • Yes, this should really be Maven's feature. But it's not there and people are forced to some [ugly Ruby hacks involving Nexus REST API](http://stackoverflow.com/a/31011010/122727) – kubanczyk Mar 19 '16 at 20:45

1 Answers1

7

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.
madhead
  • 31,729
  • 16
  • 153
  • 201
  • Yikes. That's not what I would call... user friendly. Thanks for the answer though. – Matt Apr 19 '22 at 20:33