Building with Maven, Tycho and Jenkins¶
We finally were able to build Eclipse artifacts with Maven and Tycho. In http://code.sidelab.es/public/optsicomres/optsicom-res-build.zip you can find an archive with an exemplary build. This archive consists on three folders and four pom.xml files, as described below.
- parent pom.xml: contains description of parent project (Optsicom RES plugin), the version, modules to build, and information about the repositories. It also specify information about the platform (Eclipse version to build against) and maven build targets.
- es.optsicom.res.client/pom.xml. Pretty simple. It builds the Optsicom RES Eclipse plugin.
- es.optsicom.res.feature/pom.xml. Builds the feature that wraps the plugin.
- es.optsicom.res-repository/pom.xml. Builds the p2 repository. THe plugin can be installed from this repository, and it can be published in a public server.
It is important to pay attention to artifact versions. I have had problems with versions from trunk, which are different from the versions shown in the zip file, and had to uncomment the <version> tag of plugin and feature to match that of MANIFEST.MF in the plugin and feature.xml in the feature.
Using Hudson/Jenkins¶
I have configured a job in Hudson to build automatically the p2 repository for Optsicom RES. These are the steps required:
Install Maven¶
I downloaded the latest Apache Maven 3 version. It was a .tar.gz archive, I uncompressed it in the home folder of the user and then copied it to a more accessible location:
sudo cp -R apache-maven-3.0.3 /usr/lib sudo ln -s /usr/lib/apache-maven-3.0.3 /usr/lib/apache-maven
Then I edited the file /etc/bash.bashrc and added the following (just above the PATH definition):
M2_HOME=/usr/lib/apache-maven M2=$M2_HOME/bin PATH="$PATH:...:$M2"
This makes maven system-wide available, so that we can invoke it from Jenkins.
Prepare the build¶
I created a folder optsicom-res in the user home and unpacked the http://code.sidelab.es/public/optsicomres/optsicom-res-build.zip file there. I adapted the pom's (which is what we will need). These files will be copied from here in each build. This is a workaround until we adapt our svn repositories and projects to work with Maven.
Configuring Jenkins¶
I added a Job in Jenkins (using free-style scripts), told it to checkout svn trunk, and then added the following three scripts to make the build and publishing the resulting artifacts:
cp /home/usuario/optsicom-builds/res/pom.xml $WORKSPACE/res/trunk ; cp /home/usuario/optsicom-builds/res/es.optsicom.res.client/pom.xml $WORKSPACE/res/trunk/es.optsicom.res.client/ ; cp /home/usuario/optsicom-builds/res/es.optsicom.res.feature/pom.xml $WORKSPACE/res/trunk/es.optsicom.res.feature/ ; cp -R /home/usuario/optsicom-builds/res/es.optsicom.res-repository $WORKSPACE/res/trunk
cd res/trunk ; mvn clean install
scp -r res/trunk/es.optsicom.res-repository/* <user>@code.sidelab.es:/var/files/public/optsicomres/client/snapshots
The first script copies the pom files and the es.optsicom.res-repository folder to the workspace area (where the build is taking place). As stated above, the folder is copied until we commit it to the svn repository, because we are still testing p2 building with Tycho. This folder is the maven module responsible of building the p2 artifacts.
The second script actually performs the build.
The third script publishes the repository in a public folder in our server, to make the snapshot available through the Eclipse "Help > Install New Software..." dialog. The p2 repository for snapshots is http://code.sidelab.es/public/optsicomres/client/snapshots.