adall26
adall26

Reputation: 19

Maven should not increment project version

Is there an option or plugin in maven which will keep the project version the same? I have looked at the versions plugin but that did not have that option.

Right now, it updates the project's version number from say 0.0.1-SNAPSHOT ==> 0.0.2-SNAPSHOT.

Is there a way to keep the the version the same? (The reason is that I want do some post build updates to the pom but do not want to necessarily update the project version number)

Thank you.

Upvotes: 1

Views: 2529

Answers (2)

Stephen Connolly
Stephen Connolly

Reputation: 14096

Just tell the release plugin to keep the version the same, e.g.

mvn -B -DreleaseVersion=0.0.1.7 -DdevelopmentVersion=0.0.1-SNAPSHOT

and next release

mvn -B -DreleaseVersion=0.0.1.8 -DdevelopmentVersion=0.0.1-SNAPSHOT

The downside is that you need to remember what versions you have released.

The up side is this works really well for continuous deployment via a CI system (e.g. jenkins)

So for example you might set up a Jenkins nightly job that runs

mvn -B -DreleaseVersion=0.1.$BUILD_NUMBER -DdevelopmentVersion=0.1-SNAPSHOT

That will let your developers stay on a nice SNAPSHOT while releases run thereafter.

A fancy bit of shell scripting could extract the current version from the pom and replace -SNAPSHOT with .$BUILD_NUMBER and then invoke maven with that version to give a constant going forward solution... but this is left as an exercise to the reader

Upvotes: 3

Vic
Vic

Reputation: 1888

Normally maven doesn't do that. You are probably using autoincrement-versions-maven-plugin. Remove it from your pom.xml and it should stop. If it is not the issue then add your pom.xml files to your post please.

Upvotes: 3

Related Questions