user2800708
user2800708

Reputation: 2000

Can Maven query the latest version of an artifact in a repo without a pom?

Is there a maven command that will tell me what the latest version of an artifact is, in some remote repository?

I can update versions in pom.xml to the latest, using the versions plugin. In this case, I want to do something different. I have an archetype which is being continuously built with versions put in a repo, 1.0.1, 1.0.2, 1.0.3 and so on. I want to query what is the latest 1.0.x available from a shell script, then install and invoke the latest archetype.

I realize I could just use SNAPSHOTS and always work with the latest snapshot. It would be nice to use released versions though.

Upvotes: 1

Views: 877

Answers (1)

user2800708
user2800708

Reputation: 2000

This works, perhaps not idea since it also copies the .jar, but I can live with that if there is not a better way:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy \
-DremoteRepository=ttp://legend:9005/nexus/content/groups/public \
-Dartifact=com.thesett.archetype:dropwizard_archetype:LATEST -Dpackaging=jar \
-DoutputDirectory=. 2>&1 | grep 'Copying.*dropwizard_archetype' \
| sed 's/.*dropwizard_archetype-//' | sed 's/\.jar//'

Also the above fails if the .jar is already there from a previous run - so needs a little bit of code to clean up after itself.

Upvotes: 1

Related Questions