I have completed build automation of Eclipse RCP application using maven/tycho. Now I want to make it more seamless. So I am checking if we can auto-increment application version with every build. for e.g. As you can see in attached picture, snapshot of .product file. enter image description here Version is 1.2.0. So with every build, it should increase the version number 1.2.1, 1.2.2, 1.2.3, and so on, without changing the version manually in product file. Once I execute the parent pom(trigger the build), it should also increment app version and complete the build process, all in one command that is mvn install. can we achieve this using maven/POM.xml or please suggest any other solution??
-
Sure, but where do you know from, which version was the last build? Do you want automatically increment the product version and then commit the product file? Or do you want to use the build number? Using the build number has the advantage that you can easily find the build. From my own experience I would recommend to use timestamp plus build number as qualifier, because the rest of the product version should be marketing driven. For the first see https://www.eclipse.org/tycho/sitedocs/tycho-extras/tycho-version-bump-plugin/index.html and for the second you can use the _maven-resources-plugin_. – howlger Jun 24 '22 at 06:59
-
Thanks for responding @howlger. I dont want to do anything with build number. Only interested to increase product version with every build and for that i dont want to commit the product file. is there anything like pom.xml can read the version number from product file and update it with increased version number on the server so that we dont need to commit the product file for every build?? – Diptish Jun 26 '22 at 08:23
-
@Diptish you can use `maven-antrun-plugin`'s `replace` task to replace a value with a variable at runtime. That won't auto-increment the version, but if you can get the incremented version into Maven as a property then you can use it that way. See https://stackoverflow.com/a/2196729 – Jakg Jul 11 '22 at 09:53
1 Answers
You can use the goal parse-version
of the org.codehaus.mojo:build-helper-maven-plugin
(documented here: https://www.mojohaus.org/build-helper-maven-plugin/parse-version-mojo.html). This will store the parts of the current version in some properties (by default, parsedVersion.majorVersion
, parsedVersion.minorVersion
and parsedVersion.incrementalVersion
). You can use such information to compute the next version number as you see fit.
Then, since you are using Tycho, you can pass these properties appropriately to the goal set-version
of the org.eclipse.tycho:tycho-versions-plugin
(https://tycho.eclipseprojects.io/doc/latest/tycho-release/tycho-versions-plugin/plugin-info.html).
Here you can see a simplified example using these two goals to remove the -SNAPSHOT
and .qualifier
: https://www.lorenzobettini.it/2020/02/remove-snapshot-and-qualifier-in-maven-tycho-builds/.
As I said, in your case, you'll have to do a few more operations to compute the next version number.

- 2,106
- 1
- 16
- 11