This is my POM file that generate a JAR artifact and it is stored in a private repository with Nexus Repository
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.home.mac</groupId>
<artifactId>hyper-dev</artifactId>
<version>0.0.1</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.home.mac</groupId>
<artifactId>hyper-test-linux</artifactId>
<version>0.3.5</version>
</dependency>
</dependencies>
</project>
I want to check two things:
Is it possible?
You can use Nexus' Rest Api to check if an artifact exists.
For example, the url
http://<your private nexus server>:8081/service/rest/beta/search/assets?group=org.home.mac&name=hyper-dev&version=0.0.1&maven.extension=jar&maven.classifier
will show you if the artifact hyper-dev
in the version 0.0.1
is available in your private Nexus.
If you want to automate the process, you can use a command line tool like wget
or curl
to access the Rest Api, as shown in the document linked above.
Remark: I would like to repeat the comment of khmarbaise that is usually not possible to upload a released artifact to Nexus if it already exists in the repository. If you want to upload it again, you have to increase the version and by doing so, create a new artifact. It would be an unwanted feature to update existing artifacts, as Maven assumes that a downloaded artifact will never change and caches them locally on every machine.
Snapshot artifacts can actually be updated, but you have asked about released artifacts.
For Nexus2 (using as example org.jboss.security:jboss-negotiation-toolkit:3.0.2.Final)
curl -I -s -u admin:admin123 http://mynexusserver/service/local/repositories/mymavenrepo/content/org/jboss/security/jboss-negotiation-toolkit/3.0.2.Final/jboss-negotiation-toolkit-3.0.2.Final.war | grep HTTP
This will print "HTTP/1.1 200 OK" if found, "HTTP/1.1 404 Not Found" if not found
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With