When deploying Release version jar to Nexus with maven-release-plugin The job failed with the following error:
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 10.235 s
[INFO] [INFO] Finished at: 2017-11-01T18:38:53+09:00
[INFO] [INFO] Final Memory: 32M/578M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8:deploy
(default-deploy) on project test-lib: Failed to deploy artifacts: Could not transfer artifact
com.sample:test-lib:jar:sources:1.0.0 from/to nexus-releases ([NexusURL]/releases):
Failed to transfer file: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar.
Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
It seems that the deployment of sources.jar has failed, but when I check Nexus, it has already been uploaded. .. .. Looking at the log, it looks like ** source.jar has been deployed twice **. When I stopped creating source.jar as a trial, the same phenomenon occurred in ** javadoc.jar **.
[INFO] [INFO] --- maven-deploy-plugin:2.8:deploy (default-deploy) @ test-lib ---
/* jar,Pom deployment omitted*/
[INFO] Uploading: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar
[INFO] Uploaded: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar
[INFO] Uploading: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-javadoc.jar
[INFO] Uploaded: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-javadoc.jar
/*Source again.Deploying the jar*/
[INFO] Uploading: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar
///An error occurs here
Like a maven bug. As of November 2017, it has not been closed yet. https://issues.apache.org/jira/browse/MNG-5868 https://issues.apache.org/jira/browse/MNG-5939
If you execute mvn -Prelease-profile help: effective-pom
and see the pom that actually works, execution is double-defined as follows. (In my pom, only the upper definition was described)
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
As above, run mvn -Prelease-profile help: effective-pom
to find the execution you didn't specify.
Then add the id listed there to pom.
(In my case, the id of source-plugin was attach-sources and the id of javadoc-plugin was attach-javadocs)
pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
With the method of Countermeasure 1, we were able to successfully release the Release version.
Recommended Posts