How to build a RAP application with Tycho

How to build a RAP application with Tycho

Recently I played around a little with Tycho because we evaluated it for the use in the RTP project. As a test case, I decided to try to build a RAP application with Tycho. With building I mean compiling and packaging the artifacts into a WAR file in order to deploy them on a Tomcat or another Servlet Container.

I have to say that I’m really impressed with Tycho. Before this experience, Maven was the “bad thing that downloads the internet” to me. Okay, it still downloads the internet but in this case it’s very useful. You can add p2 repositories to resolve dependencies and it automatically downloads the right bundles. You can define the dependencies in your MANIFEST.MF and use the pom.xml to describe what kind of package it is, e.g. a feature or bundle. For building the RAP application, I just had to add the Helios p2 repository to solve all my feature’s dependencies.

Now, you might want to know how to build the application with Tycho yourself. I published the code on github [1]. It’s just the example Mail application and a sample feature that can be built with Tycho. Follow the README instructions to run the build. Here are a few notes you might need if you want to use this configuration as a template for your own build:

  1. Edit the feature.xml from com.eclipsesource.maildemo.tycho.feature, adding your dependencies.
  2. The build uses a static configuration.ini. As a result, you have to edit the configuration manually and add your own bundles. You will find the configuration.ini in the com.eclipsesource.maildemo.tycho.feature feature in the templates/WEB-INF/eclipse/configuration folder.
  3. Create a pom.xml for every bundle you created with the following content:
  4. Change the artifactId from com.eclipsesource.maildemo.tycho to your own Id.  You’ll also need to change the parentId when you use your own Id.
  5. Edit the pom.xml in the parent folder and add your modules. To add modules you just need to add the folder names from the different bundles to the file.
  6. In the pom.xml of the feature, change the naming of the “maildemo” to create a .war file with the name of your choice.
  7. Of course you can use your own groupIds and artifactIds. But, you have to reference the parent pom.xml artifactId in every bundle’s pom.xml

I hope these steps and the example build will help you to create your own Tycho based builds for RAP applications. Maybe you have some experiences or ideas you’d like to share?  Please feel free to post comments.