Difference between revisions of "Tycho/FAQ"

From Eclipsepedia

Jump to: navigation, search
(ClassCastException FAQ)
(redirect target platform question to new page)
Line 161: Line 161:
 
== How should I define the target platform of my tycho project? ==
 
== How should I define the target platform of my tycho project? ==
  
There are basically two options for defining the target platform of tycho projects:  
+
This question is answered here: [[Tycho/Target Platform]]
 
+
#you don't care about individual bundles and versions, just resolve everything that's available from p2 repositori(es) you build against <br>=&gt; use [http://wiki.eclipse.org/Tycho/Reference_Card#Repository_providing_the_context_of_the_build repository entries with layout "p2" in your (parent) pom]
+
#you want control over which bundles / versions from p2 repositories are visible to the build <br>=&gt; use a [http://wiki.eclipse.org/PDE/Target_Definitions target definition] file. This has the added benefit that you can use the same target definition file for both headless tycho build as well as IDE build with PDE.
+
  
 
== My build fails with a ClassCastException of a Tycho class. What is wrong? ==
 
== My build fails with a ClassCastException of a Tycho class. What is wrong? ==

Revision as of 10:09, 26 October 2011

Contents

How to configure HTTP proxy settings during test execution?

Two options:

Manually configure the proxy

<build>
  <plugins>
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-surefire-plugin</artifactId>
      <configuration>
        <argLine>-Dhttp.proxyHost=myproxy -Dhttp.proxyPort=1234</argLine>
      </configuration>
    </plugin>
  </plugins>
</build>

and disable the eclipse system proxy setting

    if (Platform.isRunning() && getProxyService() != null
      && getProxyService().isSystemProxiesEnabled()
      && !getProxyService().hasSystemProxies()) {
      // XXX e3.5/gtk.x86_64 activate manual proxy configuration which
      // defaults to Java system properties if system proxy support is
      // not available
     getProxyService().setSystemProxiesEnabled(false);
     getProxyService().setProxiesEnabled(true);
    }

- 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:

<build>
  <plugins>
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-surefire-plugin</artifactId>
      <configuration>
        <dependencies>
          <dependency>
            <type>p2-installable-unit</type>
            <artifactId>org.eclipse.core.net.[YOUR_PLATFORM]</artifactId>
            <version>[VERSION]</version>
          </dependency>
        </dependencies>
      </configuration>
    </plugin>
  </plugins>
</build>


How to use SWTBot or some UI tool for testing?

You need to configure the tycho-surefire-plugin to use the UI:
<build>
  <plugins>
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-surefire-plugin</artifactId>
      <configuration>
        <useUIHarness>true</useUIHarness>
        <useUIThread>false</useUIThread>
      </configuration>
    </plugin>
  </plugins>
</build>

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

To configure warnings:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-compiler-plugin</artifactId>
  <version>${tycho-version}</version>
  <configuration>
    <compilerArgument>-warn:[+|-]warning_tokens_separated_by_comma</compilerArgument>
  </configuration>
</plugin>

The available warning tokens are listed in the Eclipse help. Same applies for the

-err

argument for configuring errors.

How to build plugin-based products with platform-specific fragments?

First you need to configure all os/ws/arch environments for which you want to build. Example POM snippet:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>target-platform-configuration</artifactId>
  <version>${tycho-version}</version>
  <configuration>
  <resolver>p2</resolver>
    <environments>
      <environment>
        <os>win32</os>
        <ws>win32</ws>
        <arch>x86</arch>
      </environment>
      <environment>
        <os>win32</os>
        <ws>win32</ws>
        <arch>x86_64</arch>
      </environment>
    </environments>
  </configuration>
</plugin>

for plugin-based (as opposed to feature-based) .product files, tycho needs additional os/ws/arch attributes for the fragments in the .product file which are not required by PDE.

Example product file snippet:

<plugin id="org.eclipse.swt.win32.win32.x86" fragment="true" os="win32" ws="win32" arch="x86"/>
<plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true" os="win32" ws="win32" arch="x86_64"/>

How to test OSGi declarative services?

You need to add bundle org.eclipse.equinox.ds to the test runtime:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-surefire-plugin</artifactId>
  <configuration>
    <dependencies>
      <dependency>
        <type>p2-installable-unit</type>
        <artifactId>org.eclipse.equinox.ds</artifactId>
      </dependency>
    </dependencies>
  </configuration>
</plugin>

How do I include rootfiles?

Tycho provides partial support for PDE-style rootfiles. Rootfiles are associated and installed with a feature. See 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 [1].

How should I define the target platform of my tycho project?

This question is answered here: Tycho/Target Platform

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.