From Fedora Project Wiki

Line 13: Line 13:
Fedora Tycho versions :
Fedora Tycho versions :
* rawhide : 0.19.0
* rawhide : 0.20.0
* f20 : 0.19.0
* f20 : 0.19.0
* f19 : 0.18.1
* f19 : 0.18.1

Revision as of 15:13, 25 March 2014


To document and comment upon the integration of Tycho into Fedora.


Upstream :
Fedora Tycho Repository :
Koji Builds :
Package ACLs :
Bugs :

Fedora Tycho versions :

  • rawhide : 0.20.0
  • f20 : 0.19.0
  • f19 : 0.18.1

Packages currently having a BuildRequire on Tycho :

cbi-plugins, eclipse, eclipse-cdt, eclipse-checkstyle, eclipse-dltk, eclipse-eclemma, eclipse-egit, eclipse-egit-github, eclipse-fedorapackager, eclipse-gef, eclipse-jbosstools, eclipse-jgit eclipse-linuxtools, eclipse-m2e-core, eclipse-moreunit, eclipse-mpc, eclipse-mylyn, eclipse-packagekit, eclipse-photran, eclipse-pydev, eclipse-rse, eclipse-shelled, eclipse-swtbot, feclipse-maven-plugin, jacoco, sisu, swt-chart, tycho, tycho-extras

Differences from Upstream

Criteria For A New Build

As Tycho becomes more common for building Eclipse plugins, a set of standards should be set in place so as to minimize failures resulting from changes in this package (upstream or Fedora specific).

  1. Avoid pushing changes that would break other builds
  2. In the case where (1) cannot be done, provide some way (perhaps a build flag) for consumers to maintain their old functionality
  3. In the case where (2) cannot be done, inform affected Fedora maintainers of the situation so that they may make an informed decision ahead of time

Local vs. Remote Repositories

Tycho should respect the state from which the maven build was initiated. Launching a maven build through XMvn (xmvn/mvn-build/%mvn_build) should cause the resolution of Fedora Tycho, and depending on whether an online/offline functionality is set, Tycho will resolve its artifacts accordingly. That is :

When maven is running through XMvn, and offline mode is set, Tycho will resolve its dependencies using only local resources. (eg. reactor cache, system local p2 repository). When maven is running through XMvn, and offline mode is not set, Tycho will first attempt to resolve its dependencies using local resources. If a resource cannot be found locally, Tycho will check remote repositories and place resources into the reactor cache as needed. In this case, a look through the logs can determine what packages were downloaded remotely.

Local OSGi bundle resolution

Tycho should detect all system osgi bundles
Tycho should resolve against most system osgi bundles (eclipse bundles, and anything in %{_javadir}, %{_jnidir}) by default. If Tycho is not resolving certain OSGi bundles, this heading is kept as a potential workaround in the event that a solution is not readily available.

Method 1

An OSGi project wishing to build with Tycho that has OSGi dependencies must provide a local p2 repository on the system holding all of those dependencies. This is accomplished in 3 steps :

  1. Eclipse's copy-platform script is used to gather the various dependencies needed for the build and place them in a single folder.
  2. The FeaturesAndBundlesPublisher application is used to create a p2 repository on the local system.
  3. Tycho is made aware of this repository by specifying it under the list of repositories.

A rough boilerplate for the above steps would be :

(At the end of the %prep section of the specfile)

/usr/lib/eclipse/buildscripts/copy-platform SDK \
/usr/lib/eclipse cdt

eclipse -debug -consolelog -nosplash -verbose \
-application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
-metadataRepository file:/path/to/myrepo \
-artifactRepository file:/path/to/myrepo \
-source $PWD/SDK \
-compress -append -publishArtifacts

(In the project's top-level pom.xml, and within the <repositories> tag)


Method 2

A strictly simpler way of accomplishing the above (but maybe not as resilient to implementation-specifc changes) is to place the desired OSGi bundles in .m2/p2/repo-sdk . This folder should be relative to the top level pom.xml from which Maven will be executed.

mkdir -p .m2/p2/repo-sdk/plugins
ln -s *.jar .m2/p2/repo-sdk/plugins

Target Platform Configuration

By default, upstream's offering of Tycho will attempt to resolve dependencies for every environment defined for the pom's target-platform-configuration. So for example, if your plugin needs Eclipse SWT, then the build will need to have the SWT fragment for every environment defined.

With access to remote p2 repositories, we could build for any environment, but in Fedora we must only use packages already packaged, and for that particular environment. As a result building for multiple environments at once isn't easily achievable, and in some cases the environment isn't supported by Fedora at all. This can cause all sorts of failures when running a build due to environment-specific dependencies not being available.

To get around this, Fedora's Tycho will (by default) set the target platform environment to be the same as the currently running system. In some cases, certain plugins being built are tied to a certain environment, and if this does not match the system's running environment, they will fail to build. Ideally upstream should have build profiles which allow customization of what is being built. As a last resort, Fedora Tycho has the flag tycho.local.keepTarget. With this flag enabled, Fedora Tycho will behave as an upstream Tycho with regard to target platform configuration. That is, Tycho will set the target platform environment as specified in the project poms.

Multiple Tycho Versions Specified

As of Tycho 0.16.0, when a project depends upon a version of Tycho that doesn't match the system's version, it will fail. Upstream has implemented this to avoid scenarios where a project might specify multiple versions and fail at runtime with cryptic error messages. This seems to be triggered even when using a lower version and expecting any higher available version to be resolved. Fedora Tycho 0.16.0 has added the property skipTychoVersionCheck to disable this check. As of Tycho 0.18.1, Tycho version checking is ignored by default, so no action needs to be taken. In the event that version checking is desired, the tycho.enableVersionCheck property may be set. (See for more details)

Bootstrap Building

The building of Tycho in Fedora is different from most builds. You may have noticed that upstream Tycho actually uses an pre-existing Tycho instance to build itself. This is because Tycho itself contains OSGi bundles as reactor projects. As a result Tycho has a dependency on itself. In Fedora we're able to break this chain if necessary to build Tycho cleanly when a build does not already exist (none in the buildroot).

To find all Tycho components needed for the build, we look for any components that use ${tychoBootstrapVersion} as their version and add them as well as any dependencies they have on other Tycho components. These are all clearly defined in the pom.xml files and we can then picture a dependency graph of these components.

In addition to this we add any components that Tycho seems to use at runtime. as well as components.xml (tycho-maven-plugin) contain such components. Certain Tycho projects are of an 'eclipse-test-plugin' type, but despite the fact that we can skip tests, resolution and compilation phases are still run. To avoid having to build tycho-surefire-plugin and it's various dependencies for runtime availability, we can modify the actual lifecycle mapping for our bootstrapped Tycho to omit running tycho-surefire-plugin at runtime.

Once we've discovered and ordered the necessary components we perform the following steps to create a bootstrapped Tycho build :

  1. Build all required OSGi bundles in the tycho-bundles folder using a combination of javac and jar to properly package them. Where certain Tycho OSGi bundles depend on other Tycho OSGi bundles, or external OSGi bundles we set the classpath appropriately.
  2. Place the built OSGi Tycho bundles into the reactor cache as if we had run mvn org.apache.maven.plugins:maven-install-plugin:${install-plugin.version}:install
  3. Build all reactor projects on an individual basis as required using xmvn -f ${proj}/pom.xml -Dmaven.test.skip=true -Dmaven.repo.local=$(pwd)/.m2 install

Once this is completed, we may perform a real build ensuring that Tycho will resolve itself entirely from the reactor cache we have built up.

Even when building a newer Tycho with the same version as the previous, we must actually build twice to avoid any cyclic dependencies. The first build modifies the version to be different from the previous (often ${version}-SNAPSHOT which is different from ${version}). We can think of this first built version as an "intermediary" build. The second build removes the "SNAPSHOT" so that a proper build may take place that depends on the intermediary build. Note that upstream has confirmed this would have to be done :

Missing Eclipse Parent POM

Many Eclipse projects building at the foundation use an eclipse parent pom to reference various things that most projects would have in common. While this is encouraged for upstream builds, Eclipse does not currently ship this parent pom in Fedora and references to it should be removed. See for more details.