Building with Tycho – part 1 (OSGi bundles)

Maven is as many of us know a good tool for managing dependencies between components. However, when developing OSGi bundles or Eclipse plugins, we typically want to specify our dependencies as imported/exported packages in our Manifest. This has caused trouble for headless building of OSGi bundles for some time although there exist some solutions such as PDE build and BND tool.

The Tycho project provides plugins to Maven which will make it possible (and rather simple) to build OSGi bundles with Maven . There is currently a project overview which provides a good starting point (although some of the documentation is quite outdated). The best source for help is the Tycho users mailing list.

This post will be the first in a series of posts covering building OSGi bundles/Eclipse RCP applications with Tycho.

It is important to remember that Tycho relies on new features of Maven which is only currently available in the 3.0 version of Maven which has not yet been released, but it is possible to try this out by downloading an alpha version of Maven 3.0.

Environment setup

I downloaded the alpha-6 from the Maven download site. I also set up my environment to use mvn3 instead of mvn for Maven 3 since I didn’t want to break my Maven 2 installation.

Since Tycho has been pushed to Maven central since version its last couple of revisions (0.5.0 i think), we don’t need to download anything else or setup any additional Maven repositories.

Building OSGi bundles

Fire up Eclipse (I use 3.5.1) and create a new project. Choose plug-in project and choose the target to be Equinox runtime. This creates a simple bundle without any plugin.xml or other Eclipse-specific dependencies.

I also chose to create an Activator to have some code to compile.

I recommend that you keep your source code in a different directory from the workspace. That’s my personal preference but it keeps Eclipse IDE from cluttering the source directory too much.

Open up your command line and go to the directory that contains your bundle project. In my case it looks like this:

mvn3 org.sonatype.tycho:maven-tycho-plugin:generate-poms -DgroupId=se.mattiasholmqvist -Dtycho.targetPlatform=/Users/mattias/dev/eclipse-3.5.1-delta/

Tycho is downloaded and it generates a pom.xml for the current directory (parent project) and another pom.xml for the bundle project. It should look something like:

So, Tycho has generated two poms for us. Let’s get ready to build our OSGi bundle! Try:

mvn3 clean install

and watch the magic!?

What’s the problem here? Maven tells us that it cannot resolve the project due to a missing OSGi dependency to org.osgi.framework. It considers missing OSGi dependencies as build errors. This means that we must set up a proper target platform for Tycho, and tell it to use that target platform when building. This is required for any proper build environment that builds OSGi bundles.

Currently (version 0.7.0) Tycho supports two different ways of specifying a target platform.

Building with an explicit target platform

We can expliticly tell Tycho to use an Eclipse installation using:


I downloaded the Eclipse SDK (3.5.1) and untarred it into /Users/mattias/dev/eclipse-3.5.1/. I can now build my simple bundle from the command line with:

mvn3 clean install -Dtycho.targetPlatform=/Users/mattias/dev/eclipse-3.5.1

Using an implicit target platform

If you don’t want to keep track of the target platform locally, it is possible to build the OSGi bundle with an implicit target platform. To do this, we need to help Tycho along by specifying that it should try to resolve the dependencies using a resolver. We also need to help Tycho by specifying locations (repositories) where it might find artifacts that matches our needs.

We’ll start by telling Tycho that it should use a p2 resolver (we’ll use Equinox from as our target platform). We’ll add the following to the build section pom.xml for our parent project:


This tells Tycho to use an implicit resolver that supports p2 repositories. We are now one step from being able to build with an implicit target platform.

The ${tycho.version} is a Maven property that I use to switch between versions of Tycho. This is set to 0.7.0 in my case. If you want to use just this version, replace the property with the version literals. The version of this plugin should be the same as for the tycho-maven-plugin entry that was auto-generated to the pom.xml from the generate-poms target used earlier.

We need to setup the repositories that Tycho should use at build time. This is accomplished by normal repository configuration Maven-style. Tycho enhances these configuration options by supporting p2 repositories as well. Open your settings configuration (in my case ~/.m2/settings.xml) and add the following:


It is now possible to build the simple bundle project by using:

mvn3 clean install

That’s it for now. Hope this helps with your headless OSGi builds! Keep your eyes open for the next part in this series of posts.

Some interesting links:

37 thoughts on “Building with Tycho – part 1 (OSGi bundles)

  1. Maven archetype for setting the project(s) including bundle, test fragment and update site would be great thing to have. It’s not trivial to set up tycho based project(s).

  2. Dear,

    I’m fairly new to Tycho and Maven 3.

    I’m trying to make an automatic build process for making Eclipse plugins with dependencies in the manifist to a third-party software.

    I installed maven 3, made a test plugin project without activator in Eclipse.

    I tried to follow your guide step-by-step, but i didn’t succeed.

    Is there a way i could mail you to ask some questions?


    Danny Van Dijck

    • Sure you could ask me by mail. I would like to hear which part of the guide that failed. You can also try the Tycho users mailing list, there are lots of helpful people there.

  3. I have followed the above guide but when I get to the point where I need to run:

    mvn clean install -Dtycho.targetPlatform=c:Programseclipse

    I get the error:

    Unknown packaging: eclipse-plugin

    If I change the packing type to jar in the produced pom.xml file it works. But is the whole point not that it should be possible to build eclipse plugins with maven3/tycho?

    • Hi js. You need to have access to the central maven repository to access the Tycho Maven plugins (or mirror them in an accessible repository). What does your settings.xml look like? Did you modify the repositories section for some reason?

  4. Hi Mattias,
    I am pretty new to maven, tycho and OSGi. And your post helped me a lot.
    Can you also write about how to write junit testcases in an OSGi bundles?
    do we need to create another test osgi project and have the main project as a dependency? or

    (the one i prefer)
    can we write the test cases in the same osgi bundle? can maven recognize the test cases from the actual code? will it run with a ‘mvn test’ command?


    • Hi Prasanth,

      If you take a look at my latest post (part 3) there’s an example on how to execute Junit tests from Tycho. However, these tests are in a separate bundle. I’m not sure what you would need to have them in the same bundle. In my projects, I’ve always separated the tests from the production code but I guess you could post a question on the Tycho users mailing list if you really need this feature.

      Regards, Mattias

  5. Hi Mattias,
    I have the same problem as js.
    First I build tycho 0.10.0 Snapshot and then created an plugin project described above. After the success of generating the pom.xml I tried “mvn clean install” but recieving an error “[ERROR] Unknown packaging: eclipse-plugin”
    Do you know why?

  6. I am new in the maven/tycho/eclipse-pde business but managed to build the bundle using the above steps using eclipse helios 3.6 and the eclipse-delta-pack 3.6.

    But then what? I would like to add some dependencies like google.guice to the generated pom.xml file and start writing my application. But they are not visible in eg. the file.

    I have tried to enable the maven dependency management on the project and adding eg. guice. As a result Injector is visible in the file but I cannot build the project from the commandline with maven3 any more.

    Should I use the MANIFEST file for the dependencies instead of the pom.xml file (thought the whole point was to use the pom-first approach)?

  7. Hi Tom,

    I got the same problem “Unknown packaging: eclipse-plugin”.What was incomplete and in which pom?



  8. Also, in the pom snippets above groupid should be groupId (cap the “i”) – same for artifactid (artifactId).


  9. I have tried to use tycho to build eclipse plugins for Rational Application Developer, but haven’t been able to get it working. Is that possible or is it only for standalone applications ?

    • Mi Michael,

      I have no experience from working with RAD, so I can’t help you with that. Try the Tycho users mailing list!

      Regards, Mattias

  10. Hi Mattias,

    Thanks for your really helpful article. It’s been really helpful for me. It has helped me build me own plugin with tycho version 0.10.0. However i’d like to note two things when you’re using the implicit target platform:

    There’s a small mistake with the capital letters in the xml configuration you have to add to the parent pom.xml. It should be:



    replacing artifactid for artifactId and the same for groupid.

    Also i have to say that configuring the repositories in the profile section of my settings.xml file didn’t work for me. I had to add them to the parent pom, what worked perfectly.

    Thanks anyway for your really helpful article.

  11. Hi Mattias,

    First of all congratulations for all your fantastic articles. As everybody said before they are really helpful.

    I would like to make you a question… is there a way to ask Tycho to generate the pom for a target file? I have created a project containing a target file, using the org.sonatype.tycho:maven-tycho-plugin:generate-poms, but Tycho is not generating the pom.xml file containing info about this target platform file, is there a way to have the target-platform-configuration info added to the pom.xml file automatically by Tycho?

    Thanks a lot in advance for yout help.

    Best regards.

    • Hi,

      Thanks for the positive feedback!

      I’m not aware of any such support, but I have not tried the last couple of releases of Tycho so I’m not sure if it’s available now. You could try and post a question at the Tycho Users mailing list and I’m sure you’ll get help.

      Regards, Mattias

  12. Hi Mattias,

    In a thread at a different site (not sure I am allowed to mention name here, so I just omit it) dated back in Feb/Mar 2010, you asked a question regarding target definition pointing to bundles in local file system in addition to remote download site. Just wonder if you have managed to come up with a good solution for that. Basically, I have some third-party bundles that I would like to set in the .target definition so that Tycho can use, but unfortunately Tycho does not support Directory location type.
    Did you end up having to generate a P2 repo on the local file system for the 3rd party bundles?

    Thanks, Triet

    • Hi Triet,

      Yes, I had to go all the way and create a P2 repo. It is however the right way to do it I believe. I’m not sure if there is support for local file system paths in newer versions of Tycho though. I guess you could try to post at the mailing list.

      Good luck!
      Regards, Mattias

  13. > Unknown packaging: eclipse-plugin
    If you get this error message you are propably using the wrong version of Maven. The version you can download from Apache isn’t built with tycho support.
    You’ll need to install a version of Sonatype (

    Version Camparison shows:
    From Apache: Apache Maven 3.0.2 (r1056850; 2011-01-09 01:58:10+0100)
    From Sonatype: Apache Maven 3.0-TYCHO-818442 (r818615; 2009-09-24 23:00:12+0200)

  14. Hi,

    is it possible to define the tycho.targetPlatform not as parameter or property? I would like to define the target platform in the pom.xml pointing to 2 directories (eclipse and delta pack for instance or to eclipse and rap runtime).


    • I actually never tried this on Maven 3, but if you ask the people at the Tycho mailing list, I bet they’ll know what differs between Maven 2 and Maven 3. If it’s not that important for you to use Maven 3, try using a release of Maven 2 to follow this tutorial. Good luck!

  15. Hi mattias,
    Thanks for the article. I followed the steps that you have mentioned in the article and could able to build a plugin.
    Later I tried to extend it by defining CLASSPATH VARIABLE in Java build path as M2_REPO. I added a log4j library using the M2_REPO variable and tried compiling the project using same steps defined above. But this time, I got compilation error and it seems maven-osgi-compiler-plugin is not referring to the M2_REPO classpath variable. I am stuck here and not able to proceed, can you please tell me where I am going wrong?

  16. Hi Matthias

    I have a bundle project which references (through Manifest “Require-Bundle”) other OSGi bundles I have developed. Building with Tycho I’m getting a P2 error like

    “… requires ‘bundle 1.0.0′ but it could not be found” … org.eclipse.equinox.p2.core.ProvisionException

    My bundles exist in the local Maven repo. Is there a way for having Tycho resolve bundle dependencies it finds in “Require-Bundle”, by first looking into my local Maven repository first?


  17. Hi Matthias,

    I have a use case in which a plug-in project (PDE) needs to be build using maven.

    I am following these steps:

    1. Created a simple plug-in project

    2. Ran following command to generate pom.xml :
    mvn org.sonatype.tycho:maven-tycho-plugin:generate-poms -DgroupId=tychodemo.grp -Dtycho.targetPlatform=C:/Work/IDEs/eclipse-jpaas-indogo-sr1-win64/

    Build success. Pom created using the above command.

    3. Ran following command for installation:
    mvn clean install

    Build Failed, [ERROR] Unknown packaging: eclipse-plugin @ line 8, column 14 : Added Tycho related build in pom.xml (manually)
    This manual add was required since eclipse-plugin is not known to maven, and tycho being an extension of maven knows about it.



    Using reference :

    4. Ran following command :
    mvn clean install -Dtycho.targetPlatform=C:/Work/IDEs/eclipse-jpaas-indogo-sr1-win64/

    Build Success.

    Now the build is done, is there a possibility I can eliminate the manual step of adding tycho related tags in
    pom.xml as in step 3 above, and the complete build is achieved by just commands?

    Please let me know if you need more information.

    Any help is appreciated.

    Thanks & Regards,

  18. Yes, this works if you have a dedicated module for the target definition, and make sure that the file is deployed as attached artifact. This POM [1] in the tycho-demo projects [2] shows a working example.

  19. Hi All,

    Following the tutorial I get this error by running the mvn clean install command ,

    [INFO] [Software being installed: com.uff.nomad.tychoExamples.simpleBundle 1.0.0
    .qualifier, Missing requirement: com.uff.nomad.tychoExamples.simpleBundle 1.0.0.
    qualifier requires 'bundle org.eclipse.ui 0.0.0' but it could not be found]
    [ERROR] Internal error: java.lang.RuntimeException: org.eclipse.equinox.p2.core.
    ProvisionException: No solution found because the problem is unsatisfiable. -> [
    Help 1]

    For interested people, I get fixed it by adding this content in the parent pom :


    I’m using eclipse Helios.

    Hope that can help someone

Leave a Reply

Your email address will not be published. Required fields are marked *


4 + three =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>