Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Maven release:prepare update snapshot version to the release version in batch mode

mvn release:prepare

It constantly asks me to resolve snapshot dependencies. Is there a way to do this in batch mode so that maven automatically uses the associated release. i.e. if a dependency is 1.0.0-SNAPSHOT it will automatically update this dependency to the 1.0.0 release?

[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.: Do you want to resolve them now?     (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Resolve Project Dependency Snapshots.: 'com.my.project' set to release? (yes/no) yes: : yes
What is the next development version? (0.0.2-SNAPSHOT) 0.0.2-SNAPSHOT: : 0.0.2-SNAPSHOT
like image 873
DarVar Avatar asked Jul 13 '12 16:07

DarVar


People also ask

What is release prepare maven?

Preparing a release goes through the following release phases by default: Check that there are no uncommitted changes in the sources. Check that there are no SNAPSHOT dependencies. Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)

What is batch mode maven?

Interactive means you need to type some answer in your keyboard and batch mode means no need to type anything maven is assuming defaults as answers.

What does maven release do?

This plugin is used to release a project with Maven, saving a lot of repetitive, manual work. Releasing a project is made in two steps: prepare and perform.

Is it possible to make a release from project which has snapshot dependencies?

helped in my case, this will allow to use dependencies with snapshot version to prepare and perform a release. This option should be handled very carefully, because using snapshot versions in a release can later break your release, if the snapshot dependency is updated, which in normal case is not what you want.


1 Answers

Note that you can configure Maven ignore SNAPSHOT dependencies checking by using allowTimestampedSnapshots, according to maven-release-plugin documentation:

allowTimestampedSnapshots:

Whether to allow timestamped SNAPSHOT dependencies. Default is to fail when finding any SNAPSHOT.

  • Type: boolean
  • Since: 2.0-beta-7
  • Required: No
  • Expression: ${ignoreSnapshots}
  • Default: false

Or simply run the command below:

mvn release:prepare -DignoreSnapshots=true

However, it is still recommended to resolve all SNAPSHOT dependencies before doing the final release, as it is the convention used by most people. You should always consider to do it manually at developing phase rather than automatically batching at release phase, as change/upgrade project's dependencies (either your own or third party jar) may sometimes introduce bug or incompatibility and break your project, which usually need developer's attention and fix them before doing final release.

In another word, dependency resolution is not a task which should be done at release phase, moreover, it is not a task which should be done automatically without developer's attention.

like image 190
yorkw Avatar answered Oct 03 '22 05:10

yorkw