Reputation: 2444
This may be similar to: Maven: How to check if an artifact exists?
Except I don't want to determine the existence of the artifact from within a mojo.
I want to know if the artifact exists in my repo preferably just from the command line. (ie mvn some:plugin -Drepo... -Dgroup... -Dversion... -Dartifact... etc.
The reason I want to know this is this: We have a yum repo and we are migrating it to a Sonatype Nexus repo, which is a maven repo under the covers. I don't want to "mvn deploy" a huge rpm only to have it fail because it already exists in the repo. If it exists in the repo, I don't want to deploy it.
Any ideas how I can check if an artifact exists in a maven repo without having to download it first?
Upvotes: 4
Views: 7024
Reputation: 4053
The Maven Wagon plugin can determine if an artifact exists if given a URL to a Maven repository: You will have to build that URL beforehand using groupId, artifactId, etc.
mvn wagon:exist -Dwagon.url=http://repo1.maven.org/maven2/javax/servlet/jstl/1.2
when run within your project, will produce:
[INFO]
[INFO] --- wagon-maven-plugin:1.0-beta-4:exist (default-cli) @ proj ---
[INFO] exists.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Upvotes: 2