I have a Maven pom.xml, I build project and release project deploy with Jenkins.
But before and after build "release version" we need set my version in
For example: I have in pom.xml
<properties> <version-own>0.0.21-SNAPSHOT</version-own> </properties>
before release I need set like this
<properties> <version-own>0.0.25</version-own> </properties>
after release I need set like this
<properties> <version-own>0.0.27-SNAPSHOT</version-own> </properties>
How can this be done?
mvn scm:checkin -Dincludes=pom. xml -Dmessage="Setting version, preping for release." Then you can perform your release (I recommend the maven-release-plugin), after which you can set your new version and commit it as above.
properties file in the maven project folder src/main/resources`. In pom. xml, add resources inside the building element and set filtering=true. filtering enables replacement variables from a project, or system to the resource files.
version. It is the sub element of project. It specifies the version of the artifact under given group. File: pom.xml.
If you don't have to use your own version property, consider the following that will operate on your <project><version>0.0.21-SNAPSHOT</version></project>
element:
mvn versions:set versions:commit -DnewVersion="0.0.25"
That will modify your pom and adjust the version to your liking. You'll likely want to commit this change to your source code control repository, for this the scm plugin's scm:checkin goal works just fine (assuming you want this to be automated):
mvn scm:checkin -Dincludes=pom.xml -Dmessage="Setting version, preping for release."
Then you can perform your release (I recommend the maven-release-plugin), after which you can set your new version and commit it as above.
The versions plugin is your friend. Scripting the above would likely involve some parameterized build, or preferably the groovy plugin for jenkins which allows you to get the maven-specific build variables.
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