I have configured a Jenkins job to release my maven project automatically. This is done by using the following: mvn --batch-mode clean release:prepare release:perform
In batch mode the release version and the development version will be determined automatically. This is exactly what I want.
The problem is that I want to increase the 2nd number of the version instead of the 3rd one. So when I release version 1.2.0, the next development version must be 1.3.0-SNAPSHOT. Not 1.2.1-SNAPSHOT. Adding a commandline parameter is not an option, because that forces me to constantly edit the build job.
Any suggestions on how to change the algorithm used to determine the next development version?
This means that the Release Plugin will obtain the required parameters from system properties (set on the command line) or from a properties file ( release.properties ). To prevent the Release Plugin from prompting the user for any information, Maven should be put into batch mode.
Using batch mode with no other configuration will cause the Release Plugin to use default values for the release version, the SCM tag, and the next development version. These values can also be set from the command line.
Maven2 also provided two special metaversion values to achieve the result: LATEST and RELEASE. LATEST looks for the newest possible version, while RELEASE aims at the latest non-SNAPSHOT version. They're, indeed, still absolutely valid for regular dependencies resolution.
I have configured a Jenkins job to release my maven project automatically. This is done by using the following: mvn --batch-mode clean release:prepare release:perform In batch mode the release version and the development version will be determined automatically. This is exactly what I want.
You can use build-helper-maven-plugin
. Just add following to pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${maven.build.helper.plugin.version}</version>
</plugin>
and change command to
mvn --batch-mode clean build-helper:parse-version release:prepare release:perform -DdevelopmentVersion=${parsedVersion.majorVersion}.${parsedVersion.nextMinorVersion}.0-SNAPSHOT
(please note that depending on environment you run this command in, you might need to escape $
with \
: \$
)
There is a parameter projectVersionPolicyId
provided in the release:prepare
mojo: http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#projectVersionPolicyId
There might not be built-in version policy to satisfy your needs, but you can develop your own version policy by implementing the interface VersionPolicy. You can see maven-release-yearly-policy as a reference, which provided a version policy using year in the version numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With