See also the [http://stackoverflow.com/questions/tagged/tycho?sort=faq Frequently asked Tycho questions on stackoverflow.com].

−

Two options:

+

= Compilation =

−

Manually configure the proxy

+

== How do I embed a configurable build version? ==

+

+

To cause your artifacts to be branded with the a build number, modify your manifests (<tt>MANIFEST.MF</tt>, <tt>feature.xml</tt>, etc.) to specify the version as <tt><em>X.Y.Z</em>.qualifier</tt>, and the corresponding <tt>pom.xml</tt> with <tt>X.Y.Z-SNAPSHOT</tt>. Tycho will replace the <tt>qualifier</tt> and <em>SNAPSHOT</em> with the build timestamp (in UTC).

+

+

You can set the build qualifier to a custom value by setting the <tt>forceContextQualifier</tt> property. For example:

+

<pre>mvn -DforceContextQualifier=M01 install</pre>

+

You can also set the qualifier by configuring the tycho-packaging-plugin, using some format supported by Java's SimpleDateFormat:

+

<source lang="xml">

+

<plugin>

+

<groupId>org.eclipse.tycho</groupId>

+

<artifactId>tycho-packaging-plugin</artifactId>

+

<version>${tycho-version}</version>

+

<configuration>

+

<format>'myprefix_'yyyyMMddHHmm</format>

+

</configuration>

+

</plugin>

+

</source>

+

+

Tycho does not directly support embedding the build identifier in resources. But some workarounds have been suggested in an [http://dev.eclipse.org/mhonarc/lists/tycho-user/msg01115.html email thread on tycho-user].

== How to compile pre-processed source placed in a different directory? ==

+

+

Configure your pom.xml with something like the following:

+

<pre>

+

<build>

+

<plugin>

+

<groupId>org.eclipse.tycho</groupId>

+

<artifactId>tycho-compiler-plugin</artifactId>

+

<version>${tycho-version}</version>

+

<configuration>

+

<source>${project.basedir}/YourNewSourceDirectory</source>

+

<usePdeSourceRoots>false</usePdeSourceRoots>

+

</configuration>

+

</plugin>

+

</build>

+

</pre>

+

+

== How do I include rootfiles? ==

+

+

Tycho provides partial support for [http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.pde.doc.user/tasks/pde_rootfiles.htm PDE-style rootfiles]. Rootfiles are associated and installed with a feature. See [http://git.eclipse.org/c/tycho/org.eclipse.tycho.git/tree/tycho-its/projects/TYCHO465RootFiles the TYCHO465RootFiles test] for an example of using rootfiles.

+

+

A different approach is to use the ''maven-assembly-plugin'' to assemble a zip file. We do not have a worked example, but Kai Kreuzer documented his approach that was necessary prior to the introduction of rootfile support [http://kaikreuzer.blogspot.com/2010/12/building-p2-enabled-products-with-tycho.html].

Or you can have a look at the [http://eclipse.org/tycho/sitedocs/index.html Maven site for Tycho].

+

+

== Can I use the Tycho compiler support in non-OSGi projects, too? ==

+

+

When compiling regular maven projects (e.g., packaging "jar") the plugin <code>tycho-compiler-jdt</code> can be used to tell maven to use the JDT compiler (aka "Eclipse Compiler for Java(TM)", "ecj") for compilation. This is useful to ensure that compilation in the IDE and on the build server show the same compiler messages, specifically JDT's [[JDT_Core/Null_Analysis|annotation-based null analysis]] can be integrated into the build in this way.

+

+

Use the following snippet in your <code>build.pluginManagement.plugins</code> section:

+

<!-- cannot use source tag, because the source end-tag inside the snippet would terminate the environment, geshi r50696 fixed this by introducing an alternative tag syntaxhighlight-->

+

<pre lang="xml">

+

<plugin>

+

<!-- Use compiler plugin with tycho as the adapter to the JDT compiler. -->

<!-- This dependency provides the implementation of compiler "jdt": -->

+

<dependency>

+

<groupId>org.eclipse.tycho</groupId>

+

<artifactId>tycho-compiler-jdt</artifactId>

+

<version>${tycho-version}</version>

+

</dependency>

+

</dependencies>

+

</plugin>

+

</pre>

+

+

Again, a <code>build.plugins.plugin.configuration.compilerArguments.properties</code> element can be used to reference an existing <code>org.eclipse.jdt.core.prefs</code> file (see [[Tycho/FAQ#How_to_configure_warning.2Ferror_settings_of_the_OSGi_compiler.3F|above]]).

+

+

= Testing =

+

+

== How to configure HTTP proxy settings during test execution? ==

+

+

Two options:

+

+

Manually configure the proxy

<source lang="xml">

<source lang="xml">

Line 17:

Line 180:

</plugins>

</plugins>

</build>

</build>

−

</source>

+

</source>

−

and disable the eclipse system proxy setting

+

and disable the eclipse system proxy setting

<source lang="java">

<source lang="java">

Line 32:

Line 195:

getProxyService().setProxiesEnabled(true);

getProxyService().setProxiesEnabled(true);

}

}

−

</source>

+

</source>

−

- or -

+

- or -

+

+

Make sure the native org.eclipse.core.net.* fragment for your platform is included in the test runtime so eclipse will pick up proxy settings configured on OS level:

−

Make sure the native org.eclipse.core.net.* fragment for your platform is included in the test runtime so eclipse will pick up proxy settings configured on OS level:

−

<source lang="xml">

<source lang="xml">

<build>

<build>

Line 56:

Line 219:

</plugins>

</plugins>

</build>

</build>

−

</source>

+

</source>

−

==How to configure warning/error settings of the OSGi compiler?==

+

<br>

−

To configure warnings:

+

== How to use SWTBot or some UI tool for testing? ==

−

<source lang="xml">

+

You need to configure the ''tycho-surefire-plugin'' to use the UI: <source lang="xml">

The available warning tokens are listed in the [http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm Eclipse help].

+

<tt>useUIHarness=true</tt> ensures the workbench is started before the tests are run. If your app requires a custom application class (<em>viz</em> the <tt>org.eclipse.core.runtime.applications</tt> extension point), you will likely need to [[Tycho/Reference Card#Running_an_application_or_a_product | configure the application]].

−

Same applies for the

+

−

-err

+

You may wish to add <tt>--launcher.suppressErrors</tt> to the <tt>&lt;appArgLine&gt;</tt> element to suppress Eclipse error dialogs.

See the docs http://www.eclipse.org/tycho/sitedocs/tycho-surefire/tycho-surefire-plugin/test-mojo.html#debugPort

+

+

= Diagnosing Build Problems =

+

+

== What does Tycho's message "XXXX" mean? ==

+

+

See the [[Tycho_Messages_Explained | Tycho Messages Explained]] page.

+

+

+

== My build fails with a ClassCastException of a Tycho class. What is wrong? ==

+

+

ClassCastExceptions indicate that different Tycho versions are used in the same reactor. This is not supported.

+

The problem typically occurs if some of the modules use the incorrect parent POM, e.g. an older version of the correct parent. Check the parent configuration in all modules of the reactor.

+

+

== How to switch on eclipse tracing during test execution? ==

+

+

Eclipse has a [http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Flaunchers%2Ftracing.htm platform tracing mechanism] which is switched on by using commandline option -debug and configured by putting a file named .options into the installation root.

+

You can enable this tracing mechanism for tycho test executions by running the build in debug mode using commandline option -X and putting a file .options inte the test project root.

+

+

E.g. a file .options with content

+

+

<pre>

+

org.eclipse.osgi/resolver/debug=true

+

org.eclipse.osgi/resolver/wiring=true

+

</pre>

+

+

will switch on equinox wiring tracing.

+

+

== Why is my app not working? ==

+

+

Many people post to tycho-user when they are encounter problems attempting to run their deployed applications, where the apps are missing icons, or throwing <tt>ClassNotFoundException</tt> and <tt>NoClassDefFoundError</tt> exceptions. Most of these problems are traced to errors in the projects' OSGi/p2 metadata. Some common issues are:

+

+

* a bundle declares a runtime dependencies as optional, but the dependency is actually not optional;

+

* the <tt>build.properties</tt> does not include some key directories or resources;

+

* the class files are not being bundled into a library, but the classpath does not include ".".

+

+

Tycho is not the cause of these issues, but Tycho does help "discover" these issues.

Often times eclipse.org redirects P2 repository requests to a misconfigured/broken/unavailable P2 mirror repository and builds fail because of that. To disable use of P2 mirrors and force all downloads to go directly to the main repository specify the following maven command line parameter

+

+

<pre>

+

-Dtycho.disableP2Mirrors=true

+

</pre>

+

+

= Documentation =

+

+

== Where can I find the Maven generated documentation for the Tycho plug-ins? ==

Compilation

How do I embed a configurable build version?

To cause your artifacts to be branded with the a build number, modify your manifests (MANIFEST.MF, feature.xml, etc.) to specify the version as X.Y.Z.qualifier, and the corresponding pom.xml with X.Y.Z-SNAPSHOT. Tycho will replace the qualifier and SNAPSHOT with the build timestamp (in UTC).

You can set the build qualifier to a custom value by setting the forceContextQualifier property. For example:

mvn -DforceContextQualifier=M01 install

You can also set the qualifier by configuring the tycho-packaging-plugin, using some format supported by Java's SimpleDateFormat:

How do I include rootfiles?

A different approach is to use the maven-assembly-plugin to assemble a zip file. We do not have a worked example, but Kai Kreuzer documented his approach that was necessary prior to the introduction of rootfile support [1].

What other options does the Tycho compiler support?

Can I use the Tycho compiler support in non-OSGi projects, too?

When compiling regular maven projects (e.g., packaging "jar") the plugin tycho-compiler-jdt can be used to tell maven to use the JDT compiler (aka "Eclipse Compiler for Java(TM)", "ecj") for compilation. This is useful to ensure that compilation in the IDE and on the build server show the same compiler messages, specifically JDT's annotation-based null analysis can be integrated into the build in this way.

Use the following snippet in your build.pluginManagement.plugins section:

useUIHarness=true ensures the workbench is started before the tests are run. If your app requires a custom application class (viz the org.eclipse.core.runtime.applications extension point), you will likely need to configure the application.

You may wish to add --launcher.suppressErrors to the <appArgLine> element to suppress Eclipse error dialogs.

How do I add OS-specific flags?

Some OS's may require special flags (e.g., SWT on MacOS X). The easiest way is to use a Maven profile to configure a property. For example:

Diagnosing Build Problems

What does Tycho's message "XXXX" mean?

My build fails with a ClassCastException of a Tycho class. What is wrong?

ClassCastExceptions indicate that different Tycho versions are used in the same reactor. This is not supported.
The problem typically occurs if some of the modules use the incorrect parent POM, e.g. an older version of the correct parent. Check the parent configuration in all modules of the reactor.

How to switch on eclipse tracing during test execution?

Eclipse has a platform tracing mechanism which is switched on by using commandline option -debug and configured by putting a file named .options into the installation root.
You can enable this tracing mechanism for tycho test executions by running the build in debug mode using commandline option -X and putting a file .options inte the test project root.

Why is my app not working?

Many people post to tycho-user when they are encounter problems attempting to run their deployed applications, where the apps are missing icons, or throwing ClassNotFoundException and NoClassDefFoundError exceptions. Most of these problems are traced to errors in the projects' OSGi/p2 metadata. Some common issues are:

a bundle declares a runtime dependencies as optional, but the dependency is actually not optional;

the build.properties does not include some key directories or resources;

the class files are not being bundled into a library, but the classpath does not include ".".

Tycho is not the cause of these issues, but Tycho does help "discover" these issues.

How do I disable P2 mirrors?

Often times eclipse.org redirects P2 repository requests to a misconfigured/broken/unavailable P2 mirror repository and builds fail because of that. To disable use of P2 mirrors and force all downloads to go directly to the main repository specify the following maven command line parameter

-Dtycho.disableP2Mirrors=true

Documentation

Where can I find the Maven generated documentation for the Tycho plug-ins?