How to configure maven project to deploy both snapshot and releases to Nexus?

Paul Verest picture Paul Verest · Jan 8, 2013 · Viewed 45.1k times · Source

How to configure maven project to deploy both snapshot and releases to Nexus?

<distributionManagement>
    <repository>
        <id>InternalReleases</id>
        <name>Internal Releases</name>
        <url>http://192.168.16.232:8081/nexus/content/repositories/releases/</url>
    </repository>
    <repository>
        <id>InternalSnapshots</id>
        <name>Internal Snapshots</name>
        <url>http://192.168.16.232:8081/nexus/content/repositories/snapshots/</url>
    </repository>
</distributionManagement>

This configuration creates error in Eclipse 3.8 with m2e 1.2

Project build error: Non-parseable POM D:\Workspaces\W\Parent\pom.xml: Duplicated tag: 'repository' (position: START_TAG 
 seen ...

I want the artifact deployed to the InternalSnapshots repository when the pom's version is suffixed with -SNAPSHOT and deployed to the InternalReleases repository when it is RELEASE. This should happen using the same pom.xml file and executing the same mvn deploy command.

Answer

nabcos picture nabcos · Jan 8, 2013

You need to distinguish between the releases and snapshots repository. <distributionManagement> only allows one <repository> and one <snapshotRepository> child.

http://maven.apache.org/pom.html#Distribution_Management