Search code examples
mavenosgitycho

Tycho - "Unsatisfied constraint" on an Import-Package


I'm just starting out with Tycho, and I'm stumped at an early stage. Maybe I'm misunderstanding something, so just in case, here's what I'm expecting: I define my bundle's needs in OSGi style (i.e. in MANIFEST.MF via Import-Package), and Tycho somehow uses that info on the fly instead of me needing to redefine it all in Maven style (i.e. I don't have to put dependencies in pom.xml).

So, I made a simple Maven project, in Eclipse with the m2eclipse plugin, m2eclipse-tycho add on, and PDE plugin, and put the following Tycho stuff in the pom:

<properties>
    <tycho-version>0.15.0</tycho-version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>${tycho-version}</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

Struggled through some wacky configuration errors, and finally got an essentially empty project (i.e. no source code) that gave no errors or warnings in Eclipse. Then I copied my source code from another project in, and (as expected) got a bunch of compiler errors due to missing dependencies. The first one was AbstractChannel from org.jboss.netty.channel. I use version 3.5.1.Final of Netty, so I edited my MANIFEST.MF to include:

Import-Package: org.jboss.netty.channel;version="[3.5.1,4)"

I was then expecting Tycho to somehow magically figure out that I need Netty, and therefore act as if I had inserted something like the following into my Maven pom.xml:

<dependency>
    <groupId>org.jboss.netty</groupId>
    <artifactId>netty</artifactId>
    <version>3.5.1.Final</version>
</dependency>

Instead, all that happened was I got one extra error in Eclipse, saying:

Unsatisfied constraint: 'Import-Package: org.jboss.netty.channel;version="[3.5.1,4.0.0)"

I don't know where to go from here. Do I have some fundamental misunderstanding of what Tycho is supposed to do? Or is there something else that I have to set up in order for it to be able to do the "magical" translation from a Import-Package entry in MANIFEST.MF to a <dependency> pom.xml entry? Or something else?

Thanks in advance.


Solution

  • Yeah, there are some more hurdles to take.

    In short, you will need to supply Tycho with a repository from which it can retrieve the dependencies.

    In a bit more detail:

    • you need to set up your target platform, and pass it to Tycho. I guess you've already set up your target platform in some way, otherwise Eclipse would complain too about not finding Netty.
    • Make sure you share your target platform in your workspace, so Tycho can access it too.
    • Tell Tycho to use that target platform like this
    • Tycho compatible target platforms only support p2 layouts, so no plain directories. I'm unsure what is the best way to make a p2 repo like that, as I've asked a while back. No answer whatsoever, but I do explain there what (sort of) works for me.

    Hope it helps, Frank