I've been struggling with this for quite some while.
Background: We have some Jenkins jobs that produce jars and other jobs that upload the jars to nexus. In our case we are looking for myJar-1.0.jar
and myJar-1.0-myClassifier.jar
. Obviously they are both produced with the same pom.xml
file.
What I am trying to achieve is to upload both of them on Nexus (We use Nexus2) through the REST API with a curl command using the pom.xml
.
The pom.xml
file looks something like this:
<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>my.group.id</groupId>
<artifactId>myJar</artifactId>
<version>1.0</version>
<name>My Name</name>
<packaging>pom</packaging>
<properties>
<otherJar.version>1.5</otherJar.version>
...
</properties>
<dependencies>
<dependency>
<groupId>x.y</groupId>
<artifactId>art</artifactId>
<version>{$otherJar.version}</version>
</dependency>
...
</dependencies>
</project>
The curl command that I'm using to upload (the jar without the classifier) is:
curl -v -F r=releases -F hasPom=true -F e=jar -F [email protected] -F [email protected] -u user:pass http://link/to/nexus/service/local/artifact/maven/content
and this works as expected. The jar is uploaded to nexus with the groupid, artifactid and version mentioned in the pom.xml file.
My question is - after I upload this jar, how can I upload the jar with the classifier
provided we have the same pom.xml
?
- Should I alter the
pom.xml
file? If so, how? - Should I modify the curl command? I tried adding
-F c=myClassifier
but that didn't work. That resulted in an error produced by Nexus:<html><body><error>Repository with ID='releases' does not allow updating artifacts.</error></body></html>
(because there is already an artifact with same groupid, artifactid and version - the one that I just uploaded; it seems that the classifier is ignored)