Sunday, January 6, 2013

Tycho build 1: Building plug-ins

Tycho is a great build tool for all your RCP build needs. It is a plug-in to maven and helps you to set up a reproducible build process which can be run interactively from your IDE or in headless mode (eg. on a build server).

While there are already some tutorials out there (Mattias Holmqvist, Lars Vogel) how to integrate tycho, I could not find one that focuses on UI integration of maven. This article was heavily inspired by a great talk during EclipseCon by Jan Sievers and Tobias Oberlies.

I will set this up as a series of posts. We will start by building a single plug-in and end up with a whole application built with tycho.

During the tutorial I will use a plain installation of Eclipse for RCP and RAP Developers, Mars. No external programs are needed (so you don't need to install maven separately).

Tycho Tutorials

For a list of all tycho related tutorials see Tycho Tutorials Overview

Source code for this tutorial is available on github as a single zip archive, as a Team Project Set or you can browse the files online.


Before we start using tycho I created a short sample project consisting of a small eclipse-like product along with an additional feature. The latter contains one plug-in that provides a custom toolbar entry and an (almost empty) view.
 You can grab the initial sources from github as a single zip archive, as a Team Project Set or you can browse the files online. 

Step 1: Install Tycho connector

Eclipse for RCP and RAP Developers already comes with m2e, the maven integration tools of eclipse. Maven itself needs to be extended with tycho to allow to build plug-ins and other RCP like things.

Go to Preferences/Maven/Discovery and click on Open Catalog. Find and select the Tycho Configurator.

Install it and restart eclipse.

Step 2: Build a simple plug-in project

We will start by building com.codeandme.tycho.plugin. Right click on the project and select Configure/Convert to Maven Project.

The wizard asks for a Group Id. Use a name that represents the component you want to build. Think of a component as a thing to assemble like my_product or JDT, PDE, ... you get the point. All projects that belong together will get the same Group Id.

Leave the Artifact Id to the name of your project. Actually it should match the Bundle-SymbolicName found in MANIFEST.MF.

Version should be set accordingly to Bundle-Version from the manifest. Later we will see how to keep those consistent. SNAPSHOT in maven is similar to qualifier in you plug-in version.

Finally Packaging tells maven what type of build instructions to use. Set it to eclipse-plugin.

Maven creates a pom.xml for you which we immediately replace with this one:

<project xmlns="" xmlns:xsi=""


  <!-- add Mars repository to resolve dependencies -->

    <!-- enable tycho build extension -->
Lines 9-11 add a property for the tycho version to be used. For future tycho versions you will need to upgrade this.
Lines 13-20 add the Mars p2 repository for resolving dependencies during build time.
The build section (lines 22-32) tells maven to use the tycho plug-in for the build process.

Now you will see one error in your Problems View:

We will face this error each time we convert a project to maven. To get rid of it select it in the Problems View and use the Quick Fix (from the context menu or by pressing Ctrl-1).You might face other error markers too, that indicate that some maven plugins cannot be found. They should valish after the first build, which will fetch all the requirements.

Time to build our bundle: Right click on the project and select Run As/Maven build... Under Goals enter clean install. Goals are related to the maven lifecycle. See it as something similar to make targets if you are used to that. Basically we tell maven to delete previous build artifacts, to build our plug-in and to install build results.

The first run will take some time as dependencies need to be downloaded from the Mars p2 site and from the maven central. At the end you should see something like this in your Console View:
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.128s
[INFO] Finished at: 2015-07-30T14:11:20+02:00
[INFO] Final Memory: 58M/139M
[INFO] ------------------------------------------------------------------------

Now check your project to find a new folder called target. It contains your build artifacts along with intermediate build files. Tycho will not refresh your workspace, so you have to do that manually to see the content of your target folder. If you want eclipse to do this automatically then open the run target you created before, switch to the Refresh tab and refresh The project containing the selected resource.

Additionally tycho changed your .classpath file to write output to target/classes instead of the default bin folder.

Congratulations, you've just built your first plug-in with tycho.

Optional: Proxy support

If you need to access the internet via a proxy, check out tutorial 2 first to see how to set the proxy server in maven.


  1. After installing eclipe-rcp and the tycho configurator I imported the projects. Then I select in the context menu "Configure - Convert to Maven project".

    Under "packaging" there are "jar", "war" and "pom". There isn't the selection "eclipse-plugin"?

    1. You are right. M2e will not list those tycho packaging types. You have to type them instead of selecting...

    2. If I enter them explicitly, I got an error message, which I don't know how to fix

    3. Please be a bit more specific. Which error message did you get after which step of the tutorial?

    4. Hi. Great tutorial, but unfortunately I've got similar problem so I've wrote explicite packaging type as "eclipse-plugin". Then update project and... when I'm running it as maven build I'm getting below exception:
      Exception in thread "main" java.lang.NoSuchMethodError: org.apache.maven.execution.MavenSession.getRepositorySession()Lorg/sonatype/aether/RepositorySystemSession;
      at org.eclipse.tycho.core.maven.utils.PluginRealmHelper.execute(
      at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.getDependencyMetadata(
      at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.setupProjects(
      at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.setupProject(
      at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(
      at org.apache.maven.DefaultMaven.doExecute(
      at org.apache.maven.DefaultMaven.execute(
      at org.apache.maven.cli.MavenCli.execute(
      at org.apache.maven.cli.MavenCli.doMain(
      at org.apache.maven.cli.MavenCli.main(
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(
      at java.lang.reflect.Method.invoke(
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(

      Do you know what could be the reason ? I'm complete greenhorn in Tycho and I'll be appreciate for help.

    5. Tycho and maven evolved over time, so it seems the tycho version we use in the tutorial does not work anymore. Replace the tycho version 0.16.0 with the current one 0.22.0 and the buid works

    6. Works ! Thanks. Now, I'm building "SNAPSHOT" jar in target. Is it possible to build plugin jar now ? (how ?)

  2. Hej! (I wrote the question)

    Thanks for your great tutorial! I have managed to migrate our project!

  3. This tutorial helped me a lot with Tycho. Many thanks!

  4. Hi Great tutorials..helped a lot
    I have a pluign which contains other plugins and feature projects.

    After Following your tutorial I am able to build pluign using tycho and I am getting deliverables in eclipsepluginupdateSite\target in zip format which is working fine for single version of eclipse.

    Now I am facing error how to configure tycho for to build multiple version of same plugin?

    In manual process I am following below steps:
    For example I want to create a plugin with version 4.8.800
    1. Delete eclipsepluignupdatesite features, pluigns, artifacts.jar and content.jar
    2. Copy previous versions features, plugins, artifacts.jar and content.jar in eclipsepluignupdatesite (e.g. previous version plugin is 4.6.612,4.7.711)
    3. Use export wizard for build plugins.
    4. Now In eclipsepluginupdatesite I found features, plugins, artifacts.jar and content.jar with contains plugin version 4.6.612, and also 4.8.800

    I copied whole eclipsepluginupdate contents under a host server url.
    When I use that url to install plugin It shows me three category 4.6,4.7,4.8
    Under each category I have plugin,, and I can install any plugin.

    Using tycho I am able to build single plugin but I am not getting how to build plugin along with previous plugins using tycho.
    Please help me out

    Thanks in advance

  5. Great tutorial, thanks.

    I manually entered the 'eclipse-plugin' text and intially had an error sth like 'error unknown-packaging: eclipse-plugin'. This went away after I pasted the new pom file in as above and did the quick fix.

    I ran it with version 0.22.0 of tycho and updated repository to use luna, and that worked great.

    1. I've made exactly the same and I'm getting exception :/

    2. Project build error: Unknown Packaging: eclipse-plugin.
      When i set to ecplise-plugin.

  6. I get the following error when trying to paste in the packaging tag:
    Plugin execution not covered by lifecycle configuration: org.eclipse.tycho:tycho-packaging-plugin:0.22.0:build-qualifier (execution: default-build-qualifier, phase: validate)

    When I try the quick fix it wants to install groovy but it can't because it conflicts with eclipse java development tools. Any ideas?

    1. will vanish after the first build. It simply states that eclipse did not cache the needed maven plugins yet. You may safely ignore this error

  7. Hi Christian ,
    I am developing one maven plugin which will be used to override the default maven lifecycles and will use my code instead. I have multiple jar dependencies (eclipse and my another application plugins) for the same. I have p2 repo for those jars. How can I integrate this two to resolve all dependencies? Tycho can not be used as it can only be used for RCP application (my understanding / misunderstanding). I want to use tycho with packaging type 'maven-plugin'. Is there any other way?

  8. I get the error, but the Quick fix conetext menu is disabled. Any ideas.

  9. hi,

    can any one tell, to How to run or deploy above mentioned tycho project in the eclipse, i dont no much about this thing, i am new for this trying to develop plugin and got stucked.



  10. I think about it is most required for making more on this get engaged spicewood custom pool builder