Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automate version number update process for my Eclipse plugin built with Maven

I working with a project similar to the project described here. So, it has a few modules in parent pom.xml:

 <modules>
    <module>../de.vogella.tycho.plugin</module>
    <module>../de.vogella.tycho.feature</module>
    <module>../de.vogella.tycho.p2updatesite</module>
 </modules>

These modules have a general version number e.g. 1.0.0-SNAPSHOT or without -SNAPSHOT. The feature.xml file needs to contain the same version number:

<feature
      id="com.my.feature"
      label="My plugin feature"
      version="1.0.0">

and:

<plugin
      id="com.my.plugin"
      download-size="0"
      install-size="0"
      version="1.0.0"
      unpack="false"/>

The files category.xml (in p2 update-site projects) and MANIFEST.MF (in plugin projects) need to contain the same value.

The question is: How to automate the version number update process in all these files using Maven?

I tried to resolve this problem using maven-release-plugin and maven-versions-plugin. The first plugin makes a lot of unused actions (like making a lot of CVS commits, which I do not use in this project). The second plugin only makes changes in pom.xml files and do not modify feature.xml, category.xml and MANIFEST.MF, or I used it not so good.

like image 412
Dmitry Gridyushko Avatar asked Jul 17 '12 11:07

Dmitry Gridyushko


2 Answers

There is a special tycho-versions-plugin for exactly this problem. It (intentionally) does the same as the maven-versions-plugin, but also updates the (redundant) versions in feature.xml and MANIFEST.MF.

Even more, the plugin also updates references which specify an exact version, like references to plug-ins in a feature.xml, or references to features in a category.xml. So in the end, all occurrences of the artifact versions are updated, like in a refactoring.

For references with exact versions, there is also an automatic update during the normal Tycho build. So if e.g. your feature references your plug-in in version 1.0.0.qualifier, this version string is updated with the actual value of the qualifier, e.g. 1.0.0.201207171147. You can make use of this functionality to minimize the number of places that need to be updated by the tycho-versions-plugin: Instead of specifying the current version literal in the reference, you can use the magic version 0.0.0. This version is also automatically updated to the latest version as part of the normal build.

like image 106
oberlies Avatar answered Oct 19 '22 02:10

oberlies


I'd like to add some practical hints for less experienced maven users like me to Tobias Oberlies' answer:

The goal tycho-versions:set-version will change the version of all projects that are referenced from the master pom. The version strings of the maven configuration files (pom.xml) as well as the respective Eclipse/OSGi artifacts (MANIFEST.MF, feature.xml, category.xml) will be changed consistently.

To run the goal from the command line, use the following:

mvn org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=1.2.0-SNAPSHOT

The newVersion user property, 1.2.0-SNAPSHOT in this example, is the new version to be set.

The above command line will use the latest version of the tycho-versions-plugin. If a certain version of the plugin should be used, the tycho-version-plugin needs to be added to the project/build/plugins element of the master pom.

<plugin>
  <groupId>org.eclipse.tycho</groupId>  
  <artifactId>tycho-versions-plugin</artifactId>  
  <version>${tycho-version}</version>  
</plugin> 

Replace ${tycho-version} with the current version of Tycho or define a property with that name and the appropriate value.

like image 16
Rüdiger Herrmann Avatar answered Oct 19 '22 02:10

Rüdiger Herrmann