POM-less Tycho builds for structured environments

With Tycho 0.24 POM-less Tycho builds where introduced. That approach uses convention-over-configuration to reduce the number of redundant information for setting up a Tycho build. In short, that means you don’t need to create and maintain pom.xml files for bundle, feature and test projects anymore, as the whole information can be extracted out of the already existing information in MANIFEST.MF or feature.xml.

Lars Vogel shows in his Tycho Tutorial a recommended folder structure, that is also widely used in Eclipse projects.

recommended_folder_structureThe meaning of that folder structure is:

  • bundles
    contains all plug-in projects
  • features
    contains all feature projects
  • products
  • contains all product projects
  • releng
    contains projects related to the release engineering, like

    • the project containing the parent POM
    • the aggregator project that contains the aggregator POM which defines the modules of a build and is also the starting point of a Tycho build
    • the target definition project that contains the target definition for the Tycho build
  • tests
    contains all test plug-in/fragment projects

This structure helps in organizing the project. But there is one convention for POM-less Tycho builds that is not working out-of-the-box with the given folder structure: “The parent pom for features and plugins must reside in the parent directory”. Knowing about the Maven mechanics, this convention can also be satisfied easily by introducing some POM files that simply connect to the real parent POM. I call them POM-less parent POM files. These POM-less parents need to be put into the base directories bundles, features and tests. And they do nothing else than specifying the real parent POM of the project (which is also located in a sub-directory of releng.

The following snippet shows a POM-less parent example for the bundles folder:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/maven-v4_0_0.xsd"> 

    <modelVersion>4.0.0</modelVersion>

    <artifactId>org.fipro.example.bundles</artifactId>
 
    <packaging>pom</packaging>

    <parent>
        <groupId>org.fipro.example</groupId>
        <artifactId>org.fipro.example.parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../releng/org.fipro.example.parent</relativePath>
    </parent>
</project>

For the features and tests folder you simply need to modify the artifactId accordingly.

Note that you don’t need to reference the POM-less parent POM files in the modules section of the aggregator POM.

Following the best practices regarding the folder structures of a project and the conventions for POM-less Tycho builds, you will have at least 7 pom.xml files in your project.

  • parent POM
    the main build configuration
  • aggregator POM
    the collection of modules to build
  • target-definition POM
    the eclipse target definition build
  • product POM
    the eclipse product build
  • POM-less parent POM for bundles
    the connection to the real parent POM for POM-less plug-in builds
  • POM-less parent POM for features
    the connection to the real parent POM for POM-less feature builds
  • POM-less parent POM for tests
    the connection to the real parent POM for POM-less test plug-in builds

Of course there will be more if you provide a multi-product environment or if you need to customize the build of a plug-in for example.

With the necessary Maven extension descriptor for enabling the POM-less Tycho build (see POM-less Tycho builds), the folder structure will look similar to the following screenshot:

pom-less_folder_structure

I hope this blog post will help people setting up Tycho builds for their products more easily using POM-less Tycho.

 

About Dirk Fauth

Dirk Fauth is a Software Architect for Rich Client Systems working for the Robert Bosch GmbH in Stuttgart and a lecturer in Java basics for the Baden-Wuerttemberg Cooperative State University (DHBW). He is active in developing, teaching and talking about OSGi, Eclipse RCP applications and Eclipse related technologies. He is project lead of the Nebula NatTable project, Eclipse Platform committer and also a committer and contributor to several other Eclipse projects. (Twitter: @fipro78)
This entry was posted in Dirk Fauth, Eclipse. Bookmark the permalink.

6 Responses to POM-less Tycho builds for structured environments

  1. Ace says:

    Thank you for the useful information! I’ve saved a lot of time due to your post!

  2. Marco Descher says:

    Thanks a lot for the helpful tutorial!

    It is worth mentioning, however, that Jenkins currently seems unable to build Tycho pom-less builds – see

  3. Marco Descher says:

    Seems like I messed up the link … https://issues.jenkins-ci.org/browse/JENKINS-30058

  4. Dirk Fauth says:

    I downloaded Jenkins today, installed and configured it locally on my Windows machine and created a job for the project structure in this blog post. The build works fine. I have configured Java 8 and Maven 3.3.9. The build points to the aggregator pom.xml relative via releng/org.fipro.example.aggregator/pom.xml. I’m not sure why you are facing issues with it. Maybe a version problem (Jenkins/Maven/Java)?

  5. Dirk Fauth says:

    After further investigation it looks like the issue is related to how Maven is configured. If it is configured to be installed by Jenkins the org.codehaus.plexus.classworlds.launcher.Launcher is used to start the build. Locally I configured the MAVEN_HOME directory manually, which leads to the usage of the mvn command. I investigate further, but it looks promising and hopefully helpful for the Jenkins team then.

  6. Dirk Fauth says:

    I have to correct myself. The issue seems to be related to the Maven project type. If you create a Freestyle project and configure the Maven build there, everything is working fine.

Comments are closed.