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

11,076

Solution 1

You can do update of the SNAPSHOT's via the versions-maven-plugin before the release.

Solution 2

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.

Solution 3

If your dependency is a program of you own and its lifecycle is closely linked to the one you try to release, you may think about using a multimodule project : http://maven.apache.org/guides/mini/guide-multiple-modules.html. Maven release plugin would update version for all of you dependencies modules.

If not, you are probably doing something you should not. Just changing 1.0.0-SNAPSHOT to 1.0.0 does not ensure you app will continue to work. So does not consider that Maven should !

Further considerations

Maven release plugin checks if you are using a snapshot dependency, because Snapshot, by definition, are unstable vesions. It may change along the time. That means what was working today may not work tomorrow.

Releasing means that your version is stable, and the build can be reproduce anytime without any change. Using Snapshot version, this assertion become false.

So,

Share:
11,076
DarVar
Author by

DarVar

Updated on June 08, 2022

Comments

  • DarVar
    DarVar about 2 years

    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
    
  • Srijani Ghosh
    Srijani Ghosh over 8 years
    I am facing the same plugin(versions-maven-plugin 2.2) for this purpose. But, for some reason, it is not working.I am simply using - versions:use-releases and the initial version of my project is 1.0.0-SNAPSHOT. Any solution for that? Thanks!!