Tycho Buildtimestamp SVN

Introduction

When I program a piece of software that is more than just test and throw away, I use continuous integration. I put the source code in my subversion and let Jenkins build it all for me. Most of the time I am building Eclipse bundles, either it’s a plugin for the Eclipse IDE or a RCP or a simple jar as a bundle, just in case. Since the “Create Ant Build File” option is only a snapshot of the current settings for the build using an Ant script and you have to reclick that button every time you change some settings in the project, it’s not my preferred way of building plugins. For a long time I used Buckminster for building plugins, update sites and products. I like it because it uses the same settings and builders as the Eclipse IDE. But when the update site of the Subversion plugin for Buckminster was down for a while, I had a look at Maven/Tycho. As a result all new projects I start are Maven/Tycho builds. It also uses the settings of the Eclipse IDE, but it is much easier to add new additional headless builders.

Image showing the popup for the ANT build script generation.

Versions

One thing that is different between normal Maven builds and Eclipse bundles is the versioning. With Maven normally you build SNAPSHOTs and at some points in time a release. This results in versions looks like:

1.0.0-SNAPSHOT
1.0.0
1.0.1-SNAPSHOT
1.0.1-SNAPSHOT
1.0.1-SNAPSHOT
1.0.1

Eclipse bundles get versions like 1.0.0.qualifier and this qualifier is replaced during build with something. This something could be a counter for every build, or what I like more the timestamp of the last commit in the source code management.

1.0.0.v20151109-1647
1.0.0.v20151109-2047
1.0.1.v20151111-2047

Tycho Packaging Plugin

The tycho packaging plugin allows to do exactly this. The configuration looks something like:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-packaging-plugin</artifactId>
  <version>${tycho-version}</version>
  <configuration>
    <format>'v'yyyyMMdd-HHmm</format>
    <timestampProvider>jgit</timestampProvider>
    <jgit.ignore>pom.xml</jgit.ignore>
    <jgit.dirtyWorkingTree>warning</jgit.dirtyWorkingTree>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.eclipse.tycho.extras</groupId>
      <artifactId>tycho-buildtimestamp-jgit</artifactId>
      <version>${tycho-version}</version>
    </dependency>
  </dependencies>
</plugin>

Problem is I am using Subversion. I found a project on GitHub, but it was not released anywhere, so I had to build it myself and install it locally. And if you don’t want to use a svn.ignore you got a nice NullPointerException. So I forked it, corrected the bug and published it on sonatype. It’s called tycho_buildtimestamp_svn and the configuration looks like the following:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-packaging-plugin</artifactId>
    <version>${tycho-version}</version>
    <dependencies>
        <dependency>
            <groupId>de.fx-world</groupId>
            <artifactId>tycho-buildtimestamp-svn</artifactId>
            <version>0.19.0</version>
        </dependency>
    </dependencies>
    <configuration>
        <timestampProvider>svn</timestampProvider>
        <svn.ignore>pom.xml</svn.ignore>
    </configuration>
</plugin>

So if you are using a similar tool chain, have fun using it. If not, I hope you still enjoyed reading.

tycho_buildtimestamp_svn on GitHub

Leave a Reply