How can I make a separate load fragment of the Tycho platform into a test runtime for any OS?

I use Tycho to create and test some eclipse plugins. I have one package that has many platform specific fragments. I also have one test suite that uses the tycho-surefire-plugin to test the source package, which has platform-specific fragments. However, Tycho does not include the current platform fragment in the test runtime.

All platform-specific fragments look like the win64 fragment manifest below. (There are actually six fragments, one for each combination of platform I need to support.)

Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Liferay AUI Upgrade Tool Win64 Bundle-SymbolicName: com.liferay.laut.win32.win32.x86_64;singleton:=true Bundle-Version: 1.0.2.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Fragment-Host: com.liferay.ide.alloy.core Eclipse-BundleShape: dir Eclipse-PlatformFilter: (& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86_64)) Bundle-Vendor: Liferay, Inc. 

Example win64 section of pom.xml <build>

 <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <configuration> <environments> <environment> <os>win32</os> <ws>win32</ws> <arch>x86_64</arch> </environment> </environments> </configuration> </plugin> </plugins> </build> 

When I try to complete my Tycho build and run the testfire test plugin (no matter which OS I try), the correct platform fragment is not added at runtime.

I saw various posts in stackoverflow about similar issues, but in those cases the fragments loaded at the test run time were not platform specific fragments with OS filters.

+7
java eclipse maven multiplatform tycho
source share
1 answer

This is a good question, but if you know the right trick, the solution is fortunately not difficult: just configure Tycho to include a function containing all the fragments in the test runtime.

  • Create a function in the eclipse-feature module that includes all native fragments. Make sure that the platform filters for each plugin are correct: on the Plugins tab of the feature.xml editor, you need to select the correct os / ws / arch that applies in each fragment to. This is a small manual effort, but you can usually reuse this to enable your snippets to the p2 repository / update site.

  • Include this feature in a test runtime with the following POM configuration:

     <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <dependency-resolution> <extraRequirements> <requirement> <type>eclipse-feature</type> <id>fragment-containing-feature</id> <versionRange>0.0.0</versionRange> </requirement> </extraRequirements> </dependency-resolution> </configuration> </plugin> 

A potential error is the configuration of the <environments> module eclipse-feature : you do not need anything special for this module; it’s just that the module inherits the <environments> configuration from the parent POM. Please note that the parent POM must configure all the environments supported by your build, and only the fragment modules must override the global configuration.

+8
source share

All Articles