1

It is the first time I am trying to deploy artifacts using maven, and having some trouble understanding how does maven decide whether the artifact are to be uploaded to Central repository or Snapshot repository?

Is there any tag (or some other indicator) which I can use in pom.xml indicating that the artifact is final or a snapshot ?

Part from pom.xml:

<distributionManagement>
        <snapshotRepository>
            <id>Mysnapshot</id> 
            <name>My Snapshot Repository</name> 
            <url>http://url-to-snapshot-repo</url> 
            <uniqueVersion>false</uniqueVersion> 
        </snapshotRepository>
        <repository>
            <id>MyCentralBuild</id> 
            <name>MyCentralBuild Repository</name>
            <url>http://url-to-central-repo</url> 
        </repository>
</distributionManagement>
Aditya Jain
  • 1,077
  • 1
  • 12
  • 25

2 Answers2

1

When the maven-deploy-plugin gets invoked, it checks if your project's <version/> contains SNAPSHOT. If it does, it uses the <snapshotRepository/> for the deployment; if not -- the release <repository/>. Simple as that.

Furthermore, in your settings.xml you need to have a <server/> section with an <id/> which matches the one(s) defined in your <distributionManagement/>.

carlspring
  • 31,231
  • 29
  • 115
  • 197
  • Thanks @carlspring, I understand this part now. But if you read the comments I added in ivoruJavaBoy answer, I added SHNAPHOT in version and it still got uploaded to Central repo. Is this because I changed version 1.0.0 to 1.0.0-SHAPSHOT (i.e. wrong cronological order for maven )? – Aditya Jain May 14 '14 at 10:10
  • Careful with the spelling mistakes. Are you sure it's SNAPSHOT? (You have some typos above). – carlspring May 14 '14 at 10:19
0

As you can see here

The default practice should be just check if in the version is specified the SNAPSHOT qualifier...

You can see this conversation:

Community
  • 1
  • 1
ivoruJavaBoy
  • 1,307
  • 2
  • 19
  • 39
  • Thats what I assumed, but the SNAPSHOT artifact was also upload to Central repo. I first used version: 1.0.0 and it got uplaoded to central, then I changed the version to 1.0.0-SHAPSHOT, but it too got uploaded to central repo. Can it be coz I added SNAPSHOT after original 1.0.0 verison? – Aditya Jain May 14 '14 at 09:54