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.
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:
Hope it helps, Frank
Your understanding is pretty good already, but there is a small but essential piece missing: Unlike in Maven, there is no canonical default repository (like "central") in Tycho. You need to configure where Tycho shall search for resolving the OSGi dependencies.
This search scope is called "target platform" in Tycho. There are different ways so include artifacts in the target platform; the easiest one is to configure the p2 repository that contain your dependencies in the POM with an additional <layout>p2</layout>
attribute (assuming you know a p2 repository containing the dependencies.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With