Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Tycho/FAQ"

(How do I include rootfiles?)
Line 1: Line 1:
==How to configure HTTP proxy settings during test execution?==
+
== How to configure HTTP proxy settings during test execution? ==
  
Two options:
+
Two options:  
  
Manually configure the proxy
+
Manually configure the proxy  
  
 
<source lang="xml">
 
<source lang="xml">
Line 17: Line 17:
 
   </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 32:
 
     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 56:
 
   </plugins>
 
   </plugins>
 
</build>
 
</build>
</source>
+
</source>  
  
 +
<br>
  
==How to use SWTBot or some UI tool for testing?==
+
== How to use SWTBot or some UI tool for testing? ==
  
You need to configure the ''tycho-surefire-plugin'' to use the UI:
+
You need to configure the ''tycho-surefire-plugin'' to use the UI: <source lang="xml">
<source lang="xml">
+
 
<build>
 
<build>
 
   <plugins>
 
   <plugins>
Line 75: Line 75:
 
   </plugins>
 
   </plugins>
 
</build>
 
</build>
</source>
+
</source>  
  
==How to configure warning/error settings of the OSGi compiler?==
+
== How to configure warning/error settings of the OSGi compiler? ==
  
To configure warnings:
+
To configure warnings:  
  
 
<source lang="xml">
 
<source lang="xml">
Line 90: Line 90:
 
   </configuration>
 
   </configuration>
 
</plugin>
 
</plugin>
</source>
+
</source>  
  
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].
+
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]. Same applies for the  
Same applies for the
+
  
-err
+
-err  
  
argument for configuring errors.
+
argument for configuring errors.  
  
==How to build plugin-based products with platform-specific fragments?==
+
== 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:
+
First you need to configure all os/ws/arch environments for which you want to build. Example POM snippet:  
  
 
<source lang="xml">
 
<source lang="xml">
Line 124: Line 123:
 
   </configuration>
 
   </configuration>
 
</plugin>
 
</plugin>
</source>
+
</source>  
  
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.
+
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:
+
Example product file snippet:  
  
 
<source lang="xml">
 
<source lang="xml">
 
<plugin id="org.eclipse.swt.win32.win32.x86" fragment="true" os="win32" ws="win32" arch="x86"/>
 
<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"/>
 
<plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true" os="win32" ws="win32" arch="x86_64"/>
</source>
+
</source>  
  
==How to test OSGi declarative services?==
+
== How to test OSGi declarative services? ==
  
You need to add bundle org.eclipse.equinox.ds to the test runtime:
+
You need to add bundle org.eclipse.equinox.ds to the test runtime:  
  
 
+
<br> <source lang="xml">
<source lang="xml">
+
 
<plugin>
 
<plugin>
 
   <groupId>org.eclipse.tycho</groupId>
 
   <groupId>org.eclipse.tycho</groupId>
Line 153: Line 151:
 
   </configuration>
 
   </configuration>
 
</plugin>
 
</plugin>
</source>
+
</source>  
  
==How do I include rootfiles?==
+
== 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 [https://github.com/sonatype/sonatype-tycho/tree/master/tycho-its/projects/TYCHO465RootFiles the TYCHO465RootFiles test] for an example of using 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 [https://github.com/sonatype/sonatype-tycho/tree/master/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].
+
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].
 +
 
 +
== How should I define the target platform of my tycho project? ==
 +
 
 +
There are basically two options for defining the target platform of tycho projects:
 +
 
 +
#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.
  
 
[[Category:Tycho|FAQ]]
 
[[Category:Tycho|FAQ]]
 +
 +
<br>

Revision as of 05:02, 12 October 2011

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?

There are basically two options for defining the target platform of tycho projects:

  1. you don't care about individual bundles and versions, just resolve everything that's available from p2 repositori(es) you build against
    => use repository entries with layout "p2" in your (parent) pom
  2. you want control over which bundles / versions from p2 repositories are visible to the build
    => use a 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.


Back to the top