简体   繁体   中英

determine if artifact exists in a remote repo without downloading it

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM