At Sonatype we are trying very much to bring the Maven, OSGi and Eclipse worlds together and Tycho is a big part of this strategy for us. Tycho is a set of sophisticated plugins for Maven that makes OSGi bundles first class citizens in the Maven world. We use OSGi metadata, we use MANIFEST.MF files for dependency information, and we use OSGi resolving strategies.
We are earnestly trying to bridge the Maven and Eclipse worlds and today’s dev build of Tycho is another step in that direction. Today we have our first publicly available version of Tycho with implicit build target platform support. In a nutshell we deal with target platforms in much the same way we deal with dependencies in Maven. We figure out what you need, and we’ll go get it from a set of remote repositories for you.
So let’s take a look at a simple demo application which illustrates how Tycho and the new build target platform support works.
### Install the latest Tycho DEV build from the link below. It’s a Maven installation so install it as you would Maven.
Checkout demo application
svn co http://svn.sonatype.org/m2eclipse/tycho/trunk/tycho-demo/itp01
Build the application
cd itp01 $TYCHO_HOME/bin/mvn clean install -Dtycho.resolver=p2
The build may take long time, depending on your network (we’re downloading a lot of Eclipse), but eventually the Eclipse workbench is expected to appear briefly and the build will succeed shortly after that.
What’s happening under the hood
The application has two projects, tycho.demo.itp01 is a simple bundle that implements RCP application and tycho.demo.itp01.tests is a junit4 test that requires the UI thread to run.
There is a parent pom.xml that has common build configuration. Of particular interest for this demo is the repositories element, which tells Tycho to consider the Ganymede P2 repository when looking for required build dependencies.
<repositories> <repository> <id>ganymede</id> <layout>p2</layout> <url>http://download.eclipse.org/releases/ganymede</url> </repository> </repositories>
The tycho.demo.itp01 build is quite straightforward. Tycho reads bundle dependencies from the META-INF/MANIFEST.MF, resolves these dependencies from the configured repositories (ganymede P2 repository in our case), downloads all required artifacts, compiles and packages the bundle.
tycho.demo.itp01.tests is slightly more interesting. First, building the target platform of the GUI test project has an implicit dependency on the org.eclipse.ui.ide.application Eclipse plugin. Second, in order to run the tests, Tycho creates a skeleton Eclipse installation under the target/work directory. This is a configuration-only installation that references artifacts in Maven local repository.
It is important to understand that dependency resolution is performed in two steps during a Tycho build. First, it resolves content of the build target platform using one of provided TargetPlatformResolver implementations (note the -Dtycho.resolver=p2 parameter). Then it uses the Eclipse Equinox OSGi resolver to resolve actual project dependencies given the content. The P2 target platform resolver delegates resolution to a slightly augmented P2 runtime.
A few notes:
- Tycho calculates the build target platform independently for each project
- All remote artifacts are cached in the Maven local repository. Artifacts built with Tycho will be stored with the conventional Maven 2.x path structure. Artifacts built with PDE/build will have an artificial groupId=p2. You can see these artifacts under ~/.m2/repository/p2.
- Ability to configure the Target platform resolver implementation in pom.xml is planned for later 0.4.0-DEV builds
Building individual modules
Run tycho build for the test project
cd tycho.demo.itp01.tests TYCHO_HOME/bin/mvn clean install -Dtycho.resolver=p2
The build is expected to succeed relatively quickly, i.e. no downloads or remote artifacts. Similarly to the full build, you should see the Eclipse workbench briefly.
What happens under the hood
Similarly to a plain Maven build, Tycho uses the local repository to look for project dependencies when resolving target platform content. In our demo build, tycho.demo.itp01 dependencies will be resolved from the local Maven repository.
Other notes * Since the P2 target platform resolver uses P2 artifact coordinates, it will only consider Tycho artifacts installed to local repository by Tycho. So the P2 target platform resolver won’t “see” bundles built with felix/bnd, or installed with install:file or anything akin. We’ll see what we can do about that at some point in the future. But Tycho installs P2 metadata as attached artifacts. it also maintains a simplistic index of all relevant artifacts. It’s a work in progress, but we’re making significant strides.
Please remember that we have email@example.com which you can subscribe to by sending mail to firstname.lastname@example.org. We’re really looking for feedback and want to take these tools to the next level. We are planning to create more sophisticated resolving strategies (especially to create locked down sets of artifacts), and create integration with PDE via M2Eclipse but we still really want to know what users want! We’re going to let Tycho bake a little now so we can start a significant iteration on M2Eclipse which will lay the groundwork for the integration between Tycho and PDE.