简体   繁体   中英

How do I create an Eclipse plugin release using Maven and Tycho?

I am building an Eclipse project that consists of a number of plug-ins that are packed together. I have create POM files for each component and a main POM for the project. Something like this:

projectDir\releng\pom.xml <-- Parent project
projectDir\proj1\pom.xml  <-- Child project 1
projectDir\proj2\pom.xml  <-- Child project 2

My build currently works by calling the parent POM which builds everything. Until now I have been building using 0.0.1-SNAPSHOT as the version of the parent POM, and in each Eclipse plug-in I have 0.0.1.qualifier as the version in the MANIFEST.MF file.

I now want to promote my latest version to 0.1.0 . From my understanding, this means that I have to go over ALL of my POM files AND MANIFEST.MF files and upgrade the version in both of them (since while the version is defined in the parent POM, it is referenced in all child POM:s).

Is this the correct way to do this or is there a way to automate the whole process and not make mistakes?

PS There is the Maven Release plugin but this won't work with Eclipse.

For the version update step of a relase process, there is the tycho-versions-plugin which knows how to consistently update the POMs and manifests.

Just go to the root of your parent/aggregator module and call

mvn org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion="0.1.0"

This will update the version of the parent project and of all child projects with the same/equivalent version as the parent project. In your case, these are all projects because the Eclipse versions 0.0.1.qualifier is considerered equivalent to 0.0.1-SNAPSHOT in Tycho.


For the remaining steps of the release process (tagging, building, pushing tags, etc.) just call the appropriate SCM or Maven commands, eg from a script. I haven't tried to use the maven-release-plugin for this (and apparently no-one else has ).

Please have a look here: Unleash Maven Plugin - Tycho Releases

The Unleash Maven Plugin is implemented as an alternative to the Maven Release Plugin and has a Tycho feature which should do exactly what you need. Furhtermore it is much more flexible, failure tolerant and has an integrated rollback feature.

I will publish some blog posts soon to promote and explain this plugin.

just some hints on how we implemented it.

It can be done with an extra plugin that does transformation of versions in MANIFEST.MF and *.product files. This plugin needs to be a lifecycle participant. @Component(role = AbstractMavenLifecycleParticipant.class) the reason for this is that is must transform and commit before the release plugin starts to look for modifications. Then it must also to transformation back after the release.

The mojo executor plugin saves a good deal of work since it can call the replacer, buildhelper and scm plugin from inside your plugin.

Another important gotcha is that you need to disable to hard coded clean invocation that tycho does by confguring the release plugin to configure the clean plugin to skip execution.

Hope this helps.

There is a new feature in tycho-1.1.0 (unreleased at the time of this post) that should support what you're trying to do.

If you've configured your pom correctly for standard maven-release + added the dep to tycho 1.1.0, you can customize your build as follows [1]:

       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-release-plugin</artifactId>
           <version>2.5.3</version>
           <configuration>
               <preparationGoals>org.eclipse.tycho:tycho-versions-plugin:${tycho-version}:update-eclipse-metadata org.apache.maven.plugins:maven-scm-plugin:1.9.5:add org.apache.maven.plugins:maven-scm-plugin:1.9.5:checkin</preparationGoals>
               <completionGoals>org.eclipse.tycho:tycho-versions-plugin:${tycho-version}:update-eclipse-metadata org.apache.maven.plugins:maven-scm-plugin:1.9.5:add org.apache.maven.plugins:maven-scm-plugin:1.9.5:checkin</completionGoals>
           </configuration>
       </plugin>
       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-scm-plugin</artifactId>
           <executions>
               <execution>
                   <id>default-cli</id>
                   <goals>
                       <goal>add</goal>
                       <goal>checkin</goal>
                   </goals>
                   <configuration>
                       <includes>**/META-INF/MANIFEST.MF, **/feature.xml, **/*.product</includes>
                       <excludes>**/target/**</excludes>
                       <message>Changing the Eclipse files versions</message>
                   </configuration>
               </execution>
           </executions>
       </plugin>

[1] This is taken directly from a tutorial that describes this new feature: https://wiki.eclipse.org/Tycho/Release_Workflow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM