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

3

12

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
Converted answered 13/7, 2012 at 16:58 Comment(2)
Have you tried to use --batch-mode of mvn ?Victorious
I had the same issue and fixed it with changing my dependency version. I had a dependency of another project of mine and it's version was 0.0.5-SNAPSHOT in my pom.xml, i changed this one as 0.0.4. and run mvn release:prepareCappadocia
V
5

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

Victorious answered 13/7, 2012 at 17:53 Comment(1)
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!!Sybilla
T
9

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.

Toil answered 14/7, 2012 at 2:13 Comment(0)
V
5

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

Victorious answered 13/7, 2012 at 17:53 Comment(1)
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!!Sybilla
I
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,

Ironsmith answered 13/7, 2012 at 22:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.