I'm trying to use the maven-deploy-plugin to upload releases and snapshots into a Nexus repository. However I run across this error
[INFO] [deploy:deploy {execution: default-deploy}]
[INFO] Retrieving previous build number from nexus
Uploading: http://localhost:8081/nexus/content/repositories/snapshots/info/afilias/edr/edr-app/1.0.4-SNAPSHOT/edr-app-1.0.4-20120605.140242-20.jar
56K uploaded (edr-app-1.0.4-20120605.140242-20.jar)
[INFO] Uploading project information for edr-app 1.0.4-20120605.140242-20
[INFO] Retrieving previous metadata from nexus
[INFO] Uploading repository metadata for: 'artifact info.afilias.edr:edr-app'
[INFO] Retrieving previous metadata from nexus
[INFO] Uploading repository metadata for: 'snapshot info.afilias.edr:edr-app:1.0.4-SNAPSHOT'
[INFO] Retrieving previous build number from nexus
Uploading: http://localhost:8081/nexus/content/repositories/snapshots/info/afilias/edr/edr-app/1.0.4-SNAPSHOT/edr-app-1.0.4-20120605.140242-20.tar.gz
4286K uploaded (edr-app-1.0.4-20120605.140242-20.tar.gz)
[INFO] [deploy:deploy-file {execution: default}]
Uploading: http://localhost:8081/nexus/content/repositories/releases/info/afilias/edr/edr-app/1.0.4/edr-app-1.0.4.tar.gz
89530K uploaded (edr-app-1.0.4.tar.gz)
[INFO] Uploading project information for edr-app 1.0.4
[INFO] Retrieving previous metadata from remote-repository
[INFO] Uploading repository metadata for: 'artifact info.afilias.edr:edr-app'
[INFO] Retrieving previous build number from remote-repository
[INFO] repository metadata for: 'snapshot info.afilias.edr:edr-app:1.0.4-SNAPSHOT' could not be found on repository: remote-repository, so will be created
Uploading: http://localhost:8081/nexus/content/repositories/releases/info/afilias/edr/edr-app/1.0.4-SNAPSHOT/edr-app-1.0.4-20120605.140242-20.tar.gz
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying attached artifact /home/mren/trunk2/target/edr-app-1.0.4-SNAPSHOT.tar.gz: Error deploying artifact: Failed to transfer file: http://localhost:8081/nexus/content/repositories/releases/info/afilias/edr/edr-app/1.0.4-SNAPSHOT/edr-app-1.0.4-20120605.140242-20.tar.gz. Return code is: 400
Here's my configuration in the pom.xml:
<project>
...
<distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
...
<build>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>target/edr-install-1.0.4-${revision}.tar.gz</file>
<url>${project.distributionManagement.repository.url}</url>
<packaging>tar.gz</packaging>
<artifactId>artifactId</artifactId>
<groupId>groupId</groupId>
<version>1.0.4-${revision}</version>
</configuration>
</execution>
</executions>
</plugin>
...
</build>
...
</project>
And from my settings.xml file:
<settings>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<profiles>
<profile>
<id>nexus</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>releases</id>
<name>Releases</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<name>Snapshots</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
I'm sure this configuration worked at one point, but now it's spitting out an error. Not sure what is wrong.
And the nexus log tells me that it's trying to upload a snapshot into a release repository
jvm 1 | 2012-06-04 14:16:31 INFO [tp1706427008-35] - org.sonatype.nexus.proxy.maven.maven2.M2Repository - Storing of item releases:/info/afilias/edr/edr-app/1.0.4-SNAPSHOT/edr-app-1.0.4-20120604.181534-1.tar.gz is forbidden by Maven Repository policy. Because releases is a RELEASE repository
jvm 1 | 2012-06-04 14:16:31 ERROR [tp1706427008-35] - org.sonatype.nexus.rest.ContentPlexusResource - Got exception during processing request "PUT http://localhost:8081/nexus/content/repositories/releases/info/afilias/edr/edr-app/1.0.4-SNAPSHOT/edr-app-1.0.4-20120604.181534-1.tar.gz": Storing of item releases:/info/afilias/edr/edr-app/1.0.4-SNAPSHOT/edr-app-1.0.4-20120604.181534-1.tar.gz is forbidden by Maven Repository policy. Because releases is a RELEASE repository
Your settings.xml is incorrect. Please configure Maven to use Nexus correctly following the book chapter. Specifically use the mirror settings and the url in there and not specific urls for repository and pluginRepository.
It interferes with your correct Maven pom and ends up trying to deploy a snapshot into a release repository, which is incorrect.
In addition it will be important that you use the correct goal/command. Do not use deploy-file goal directly or so.
Just run the command
mvn clean deploy
on the build.
And another clarification. Maven will deploy whatever is determined from the version. If it ends in -SNASPHOT is is a development version and be published to the snapshot repo (and will allow redeploys incrementing the version number) and if it does not it is considered a release and will deploy to the release repo. A project can not be a snapshot and a release at the same time. It is one or the other.
Do not mix the two concepts of release and snapshot!
And in terms of getting additional artifacts deployed I would either pull them out into a separate project/module if they are not associated or if they are look into the attach-artifact goal of the build helper plugin.