Sam Levin
Sam Levin

Reputation: 3416

How to differentiate between deploying releases vs snapshots

I may be missing something extremely obvious, but I need some clarification regardless. I am about to begin development using maven and archiva. I added both servers + settings to settings.xml, and distributionManagement tags to the maven POM which I want to deploy.

I put references to both my internal snapshot repo, and my internal release repo in the POM. is there a specific maven command or option, which specifies to deploy as a SNAPSHOT, and NOT to both repos? Or if I do deploy, will it automatically push one copy to each repo?

Can someone clarify this?´

Upvotes: 85

Views: 72329

Answers (3)

Wander Costa
Wander Costa

Reputation: 503

You can execute mvn deploy.

If your project version contains -SNAPSHOT as suffix, it will deploy into the repository configured under distributionManagement.snapshotRepository.

If your project doesn't contain -SNAPSHOT suffix, it will deploy into the repository configured under distributionManagement.repository.

However, I do recommend you to use maven-release-plugin to manage versioning and deployment. By running mvn -B release:clean release:prepare release:perform, in resume:

  • the suffix -SNAPSHOT is removed from the version (e.g. 2.1-SNAPSHOT -> 2.1);
  • the application is built so as to generate JAR files;
  • the code is committed to your code repository (e.g. git) and tagged (e.g. 2.1);
  • the JAR is deployed into your release repository (not snapshot repo);
  • the version is incremented and the suffix -SNAPSHOT is added (e.g. 2.2-SNAPSHOT).

Upvotes: 36

Andrew Logvinov
Andrew Logvinov

Reputation: 21831

If your project.version contains SNAPSHOT (e.g., 1.2-SNAPSHOT) and you execute mvn deploy, artifacts will be deployed to your snapshot repository. If it doesn't (e.g., 1.2) - they will be deployed to your release repository.

Upvotes: 128

OliP
OliP

Reputation: 81

For me putting a suffix: SNAPSHOT in ${project.version} was not enough. I had to put a dash in front of it:-SNAPSHOT in order for maven to deploy it in the local snapshot repo.

Upvotes: 6

Related Questions