I am using Nexus Repository Manager v3.1.0-04. When I attempt to mvn deploy
a jar artifact to my repository, I get the following problem.
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.5.1:deploy (injected-nexus-deploy) on project rest-service: Failed to deploy artifacts: Could not transfer artifact com.xyz:rest-service:jar:0.0.1-20180504.193415-6 from/to nexus (http://nexus.mydomain.io/repository/snapshots/): Failed to transfer file: http://nexus.mydomain.io/repository/snapshots/com/xyz/rest-service/0.0.1-SNAPSHOT/rest-service-0.0.1-20180504.193415-6.jar. Return code is: 400, ReasonPhrase: Detected content type [application/x-sh], but expected [application/java-archive]: com/xyz/rest-service/0.0.1-SNAPSHOT/rest-service-0.0.1-20180504.193415-6.jar. -> [Help 1]
I thought that maybe this was related to the version of nexus-staging-maven-plugin
(link) but even if I set the version to 1.6.8
(latest), I get the same effect. This post suggest that to use the build-helper-maven-plugin
, and so I modified my pom.xml
as follows.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/${artifactId}-${version}.jar</file>
<type>jar</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
However, I see a different problem now.
[ERROR] Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:3.0.0:attach-artifact (attach-artifacts) on project rest-service: Execution attach-artifacts of goal org.codehaus.mojo:build-helper-maven-plugin:3.0.0:attach-artifact failed: For artifact {com.xyz:rest-service:0.0.1-SNAPSHOT:jar}: An attached artifact must have a different ID than its corresponding main artifact. -> [Help 1]
Note that the Maven project is generated by Spring Initializer via IntelliJ and is a Spring Boot project. Without using the Builder Helper plugin, I can see that all files are successfully uploaded to Nexus until the jar is finished uploaded (it actually finishes uploaded, but because the content type mismatches, it fails).
Any ideas on how to resolve this issue? The post I mentioned says "some maven repositories check the file content," and so, how would I disable Nexus (which I have control over) in checking file content? But the real problem is, why is the content type application/x-sh
instead of application/java-archive
?