Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to differentiate between deploying releases vs snapshots

Tags:

maven

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?´

like image 790
Sam Levin Avatar asked Feb 27 '12 07:02

Sam Levin


People also ask

What is the difference between SNAPSHOT and release?

By definition, snapshots are mutable, releases are immutable. This is why Nexus makes you store them separately because usually you don't care if you lose snapshots, but you will care if you lose releases. It makes snapshot cleanup much easier to deal with that way.

What is SNAPSHOT in deployment?

Typically, a snapshot represents a set of component versions that are known to work together. In most cases, snapshots include all of the components in an application. A snapshot is typically created when a successful deployment runs in an uncontrolled environment, where there are no approval gates.

Why is it best practice not to release SNAPSHOT Maven artifacts to production?

Rule #3 Never release using the Time-Stamped snapshot The release plugin will still fail if you do this because it correctly understands you have SNAPSHOT dependencies. The plugin has a flag to allow bypass this check and people unfortunately use it far too often.

What is difference between SNAPSHOT and version in Maven?

A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.


2 Answers

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

like image 191
Andrew Logvinov Avatar answered Sep 21 '22 21:09

Andrew Logvinov


You can execute mvn deploy.

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

If your POM 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).
like image 22
Wander Costa Avatar answered Sep 21 '22 21:09

Wander Costa