Jump to: navigation, search

Difference between revisions of "Developing Tycho"

(stripped the troubleshooting instructions to the only problem I have encountered recently)
(461101 document update of Equinox/JDT dependency snapshots)
 
(21 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
== Importing the Tycho sources ==
 
== Importing the Tycho sources ==
  
For importing the Tycho sources into Eclipse, you need to have m2eclipse 1.0.0 or later (available from the Juno software site) installed.
+
Step by step instructions:
 +
# Get an [https://www.eclipse.org/downloads/ Eclipse IDE] with a recent version of the [http://www.eclipse.org/m2e/ Maven integration for Eclipse (m2eclipse)] and Eclipse PDE installed. m2eclipse is included in various Eclipse packages, e.g. the "Eclipse for Java Developers" package. (Note: m2eclipse is '''not''' included in an the "Eclipse for Committers" package.) To add m2eclipse to your existing Eclipse installation, install it from the [https://wiki.eclipse.org/Simultaneous_Release release train p2 repository] or from the [http://download.eclipse.org/technology/m2e/releases m2eclipse update site].
 +
# Install [http://maven.apache.org/download.html Maven] version 3.0 or later
 +
# If your Internet connection uses a proxy, make sure that you have the proxy configured in your [http://maven.apache.org/settings.html Maven settings.xml]
 +
# Get the [https://projects.eclipse.org/projects/technology.tycho/developer Tycho sources] from eclipse.org; there are different ways to do this:
 +
#* In EGit, open the ''Git Repositories'' view, select ''Clone a Git Repository'' and clone from the location https://git.eclipse.org/r/tycho/org.eclipse.tycho
 +
#* In a shell, execute <tt>git clone https:</tt><tt>//git.eclipse.org/r/tycho/org.eclipse.tycho </tt>
 +
# In Eclipse, use ''File > Import > Existing Maven Projects'', select the root directory of the sources, and import all projects. If prompted by m2eclipse, install the proposed project configurators and restart Eclipse.
 +
# Configure the target platform: Open the file <tt>tycho-bundles-target/tycho-bundles-target.target</tt> and click on ''Set as Target Platform'' in the upper right corner of the target definition editor.
  
Here is the step by step approach assuming you use a Windows OS:
+
The result should be an Eclipse workspace without build errors. m2eclipse may take some time to download required libraries from Maven central.
# Get a Juno version of [http://www.eclipse.org/downloads/index-developer.php Eclipse]
+
* If there are compile errors in the projects <tt>org.eclipse.tycho.surefire.junit</tt>, <tt>org.eclipse.tycho.surefire.junit4</tt>, <tt>org.eclipse.tycho.surefire.junit47</tt>, or <tt>org.eclipse.tycho.surefire.osgibooter</tt>, just select these projects and manually trigger an update via ''Maven > Update project...'' from the context menu.
<ol start="2">
+
* If there are compile errors in the project <tt>tycho-p2-director-plugin</tt>, right-click on the project and go to ''Build Path > Configure Build Path...'' and change the JRE System Library to JavaSE-1.7. Then revert the changes that the PDE does to the file <tt>tycho-p2-director-plugin/.settings/org.eclipse.jdt.core.prefs</tt>. (Background: The project optionally uses classes from the Java 7 library, so it needs to compile with a Java 7 JDK.)
<li> Install the following additional software into Eclipse:
+
* [http://www.eclipse.org/m2e/download/ Maven Integration for Eclipse (m2e)], version 1.0.0 or later
+
* [http://www.eclipse.org/egit/download/ EGit Team Provider] (optional)
+
<li> Install [http://maven.apache.org/download.html Maven] version 3.0 or later
+
<li> '''Window > Preferences > Maven > Installations > Add...''' and add your Maven 3 installation; activate it
+
* On OSX, Preferences is under the "Eclipse" menu.
+
<li> Get [http://git.eclipse.org/c/tycho/org.eclipse.tycho.git/ the sources] from eclipse.org; there are different ways to do this:
+
* In EGit, open the '''Git Repositories''' view, select '''Clone a Git Repository''' and clone from the location https://git.eclipse.org/r/p/tycho/org.eclipse.tycho.git
+
* In a shell (e.g. from [http://code.google.com/p/msysgit/ msysgit] or [http://cygwin.com/ Cygwin]), execute <tt>git clone https:</tt><tt>//git.eclipse.org/r/p/tycho/org.eclipse.tycho.git</tt>
+
<li> In Eclipse, use '''File > Import > Existing Maven Projects''', select the root directory of the sources, and import all projects. Install the proposed project configurators and restart Eclipse.
+
<li> Configure the target platform: Open the file <tt>tycho-bundles-target/tycho.target</tt> and click on '''Set as Target Platform''' in the upper right corner of the target definition editor.
+
<li> The result should be an eclipse workspace without build errors. m2eclipse may take some time to download required libraries from Maven central.
+
</ol>
+
  
If you get an "Error Updating Maven Configuration" for the projects org.eclipse.tycho.surefire.junit, org.eclipse.tycho.surefire.junit4, and org.eclipse.tycho.surefire.osgibooter, select just these three projects, select '''Maven > Update project...''' from the context menu and confirm the dialog.
+
== Building and Testing Tycho ==
  
== Building Tycho ==
+
To build Tycho from source, executed '''<tt>mvn clean install</tt>''' in the source root. This also runs the unit tests.
  
Tycho can be built from source by executing <tt>mvn clean install</tt> in the root directory.
+
To run all Tycho integration tests, execute <tt>mvn clean install -f tycho-its/pom.xml</tt>. To run a single integration test, select the test class in Eclipse and run it as ''JUnit Test''.
  
In order to execute the Tycho integration tests, you can use the scripts in the root of the sources:
+
=== Background information on the Tycho integration tests ===
# Edit <tt>bootstrap.cmd</tt> in the root directory and adapt the variables <tt>TYCHO_TEST_TARGET_PLATFORM</tt> -> point to Eclipse SDK 3.7.0 plus delta pack, <tt>TYCHO_M2_HOME</tt> -> point to maven 3 home directory
+
 
# Execute <tt>.\bootstrap.cmd</tt>
+
The integration tests trigger sample builds that use Tycho. These builds expect that Tycho has been installed to the local Maven repository. This is why you need to build Tycho through a <tt>mvn install</tt> before you can run the integration tests.
 +
 
 +
Alternatively, e.g. if you are only interested in modifying an integration test and do not want to patch Tycho itself, you can configure the integration tests to download the current Tycho snapshot produced by the [http://hudson.eclipse.org/tycho/view/CI Tycho CI builds]. To do this, you need to edit the Maven settings stored in <tt>tycho-its/settings.xml</tt> and add the tycho-snapshots repository as described in [[Getting Tycho]]. (Advanced note: The integration tests can also be pointed to a different settings.xml with the system property <tt>tycho.testSettings</tt>.)
  
 
== Debugging Tycho ==
 
== Debugging Tycho ==
Line 34: Line 31:
 
In order to debug Tycho plugins inside Eclipse:
 
In order to debug Tycho plugins inside Eclipse:
 
# Get Tycho sources in Eclipse
 
# Get Tycho sources in Eclipse
# create/get a project that highlight the bug
+
# Create/get a project that highlights the bug
# Run the project with '''MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" mvn clean install'''
+
# Run the project with <tt>mvnDebug clean install</tt>
# Go into your Eclipse, use Debug > Remote Java Application, select port 8000
+
# Go into your Eclipse, use ''Debug > Remote Java Application'', select port 8000
  
 
== Advanced Topics ==
 
== Advanced Topics ==
 
=== Executing integration tests in Eclipse ===
 
 
It is possible to start most integration tests directly from Eclipse. Note however that you will still need to build Tycho through a <tt>mvn install</tt> first whenever you have made changes to the Tycho code, e.g. using the <tt>bootstrap.cmd</tt> as described above. (Background: The integration tests trigger builds of test projects -- and these builds take Tycho from it's normal location, i.e. the local Maven repository.)
 
 
'''Tips:'''
 
* The integration test builds use the settings stored in <tt>tycho-its/settings.xml</tt> (they don't use the default Maven settings.xml). If you have special requirements, e.g. for proxy settings, you can edit this file. Alternatively, you can point to a different settings.xml with the system property <tt>tycho.testSettings</tt>.
 
  
 
=== Writing integration tests ===
 
=== Writing integration tests ===
Line 52: Line 42:
  
 
Therefore, here are a few tips for writing good integration tests:
 
Therefore, here are a few tips for writing good integration tests:
* Test project name: Although most existing test have a bug number in the name, this is '''not''' the recommended naming scheme. Since integration test can take some time to execute, it may be a good idea to test related things in one test. <br>So name the test projects in a way that they can be found, and that related tests are sorted next to each other, e.g. in the form <tt>&lt;feature&gt;.&lt;aspect&gt;</tt>.
+
* Test project name: Although many existing test have a bug number in the name, this is '''not''' the recommended naming scheme. Since integration test can take some time to execute, it may be a good idea to test related things in one test. <br>So name the test projects in a way that they can be found, and that related tests are sorted next to each other, e.g. in the form <tt>&lt;component&gt;.&lt;aspect&gt;</tt>.
* Package: Should be <tt>org.eclipse.tycho.test.&lt;feature&gt;</tt>
+
* Package: Should be <tt>org.eclipse.tycho.test.&lt;component&gt;</tt> (without the aspect so that we don't get an excessive number of packages)
* Test project groupIds: Should be <tt>tycho-its-project.&lt;project.name&gt;</tt> (plus a segment for the reactor in case of multi-reactor tests). The groupId is particularly important if the test project is installed to the local Maven repository. (Avoid install; use verify if possible.)
+
* Test project groupIds: Should be <tt>tycho-its-project.&lt;component&gt;.&lt;aspect&gt;</tt> plus a segment for the reactor in case of multi-reactor tests. The groupId is particularly important if the test project is installed to the local Maven repository. (Avoid install; use verify if possible.)
* Test project artifactIds: Should be the same as the ID of the feature/bundle; need to start with something unique, e.g. the first letters of each segment of the project name.
+
* Test project artifactIds: Have to be the same as the ID of the feature/bundle; need to start with something unique, e.g. the first letters of each segment of the project name.
 +
 
 +
If you have integration tests under your local sub-module (like tycho-eclipserun-plugin from tycho-extras) then you need to:
 +
* Build tycho using "bootstrap.sh"
 +
* Build tycho-extras using "mvn install -Dmaven.repo.local=/tmp/tycho-bootstrap.localrepo"
 +
* Run you integration test "mvn integration-test -Pits -Dtycho-snapshots-url=file:/tmp/tycho-bootstrap.localrepo"
  
 
=== Building Tycho against a locally built version of p2 ===
 
=== Building Tycho against a locally built version of p2 ===
  
Tycho makes heavy use of p2 functionality. Therefore it may be useful to try out patches in p2 before the next version of p2 has been released. With the following steps it is possible to build Tycho against a locally built version of p2.
+
Tycho makes heavy use of p2 functionality. Therefore it may be useful to try out patches to p2 without waiting for a new p2 release, or even just the next nightly build. With the following steps it is possible to build Tycho against a locally built version of p2.
  
# Get the p2 sources (see [[Equinox p2 Getting Started for Developers]])
+
# Get the p2 sources (see [http://projects.eclipse.org/projects/rt.equinox.p2/developer p2 project information])
 
# Make changes in the p2 sources
 
# Make changes in the p2 sources
# (Temporarily) increase the versions of the changed p2 bundles, and require these versions in the tycho-bundles-external.product
+
# Build the changed p2 bundles individually with <tt>mvn clean install -Pbuild-individual-bundles</tt> (see [[Equinox/p2/Build]] for more information)
# Build the changed p2 bundles individually with <tt>mvn clean install</tt> (a full p2 build with Tycho may not work; see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=304594 bug 304594])
+
# Build at least the Tycho module tycho-bundles-external with <tt>mvn clean install</tt> - you should see a warning that the locally built p2 bundles have been used.
# Build at least the Tycho module tycho-bundles-external with <tt>mvn clean install</tt>
+
 
Then the locally built Tycho SNAPSHOT includes the patched p2 version.
 
Then the locally built Tycho SNAPSHOT includes the patched p2 version.
  
Note: Tycho always allows references to previously built artifacts, even if they are not part of the target platform. Therefore you may want to clear the list of locally built artifacts (in the local Maven repository in .meta/p2-local-metadata.properties) after local changes a described above.
+
Note: Tycho always allows references to locally built artifacts, even if they are not part of the target platform. Therefore you may want to clear the list of locally built artifacts (in the local Maven repository in .meta/p2-local-metadata.properties) after you have finished your trials with the patched p2 version.
 +
 
 +
=== Updating the Equinox and JDT dependencies of Tycho ===
 +
 
 +
Tycho has Maven dependencies to Equinox and JDT, so these artifact need to be available in a Maven repository. Currently, the authors don't provide these artifacts in Maven central, so we deploy them ourselves (with the groupId <tt>org.eclipse.tycho</tt>). See <tt>tycho-releng/pom.xml</tt> for the technical details on how this is done.
 +
 
 +
If we want to use a new version of these dependencies in a Tycho snapshot, we can also deploy snapshot versions of these dependencies alongside with the Tycho snapshots. This is how this is done:
 +
 
 +
# Update the p2 repository in <tt>tycho-releng/pom.xml</tt>
 +
# Update the versions in the parent POM so that they match the versions available in the p2 repository. Add the <tt>-SNAPSHOT</tt> suffix to the Maven version properties.
 +
# Commit and upload the change to Gerrit. The Gerrit build will fail with a dependency resolution error.
 +
# Trigger the job [https://hudson.eclipse.org/tycho/job/tycho-deploy-dependencies/ tycho-deploy-dependencies] and make it build the proposed change
 +
# Re-trigger the voter job for the Gerrit change. The build should now pass.
  
 
[[Category:Tycho]]
 
[[Category:Tycho]]

Latest revision as of 08:26, 13 April 2015

Importing the Tycho sources

Step by step instructions:

  1. Get an Eclipse IDE with a recent version of the Maven integration for Eclipse (m2eclipse) and Eclipse PDE installed. m2eclipse is included in various Eclipse packages, e.g. the "Eclipse for Java Developers" package. (Note: m2eclipse is not included in an the "Eclipse for Committers" package.) To add m2eclipse to your existing Eclipse installation, install it from the release train p2 repository or from the m2eclipse update site.
  2. Install Maven version 3.0 or later
  3. If your Internet connection uses a proxy, make sure that you have the proxy configured in your Maven settings.xml
  4. Get the Tycho sources from eclipse.org; there are different ways to do this:
  5. In Eclipse, use File > Import > Existing Maven Projects, select the root directory of the sources, and import all projects. If prompted by m2eclipse, install the proposed project configurators and restart Eclipse.
  6. Configure the target platform: Open the file tycho-bundles-target/tycho-bundles-target.target and click on Set as Target Platform in the upper right corner of the target definition editor.

The result should be an Eclipse workspace without build errors. m2eclipse may take some time to download required libraries from Maven central.

  • If there are compile errors in the projects org.eclipse.tycho.surefire.junit, org.eclipse.tycho.surefire.junit4, org.eclipse.tycho.surefire.junit47, or org.eclipse.tycho.surefire.osgibooter, just select these projects and manually trigger an update via Maven > Update project... from the context menu.
  • If there are compile errors in the project tycho-p2-director-plugin, right-click on the project and go to Build Path > Configure Build Path... and change the JRE System Library to JavaSE-1.7. Then revert the changes that the PDE does to the file tycho-p2-director-plugin/.settings/org.eclipse.jdt.core.prefs. (Background: The project optionally uses classes from the Java 7 library, so it needs to compile with a Java 7 JDK.)

Building and Testing Tycho

To build Tycho from source, executed mvn clean install in the source root. This also runs the unit tests.

To run all Tycho integration tests, execute mvn clean install -f tycho-its/pom.xml. To run a single integration test, select the test class in Eclipse and run it as JUnit Test.

Background information on the Tycho integration tests

The integration tests trigger sample builds that use Tycho. These builds expect that Tycho has been installed to the local Maven repository. This is why you need to build Tycho through a mvn install before you can run the integration tests.

Alternatively, e.g. if you are only interested in modifying an integration test and do not want to patch Tycho itself, you can configure the integration tests to download the current Tycho snapshot produced by the Tycho CI builds. To do this, you need to edit the Maven settings stored in tycho-its/settings.xml and add the tycho-snapshots repository as described in Getting Tycho. (Advanced note: The integration tests can also be pointed to a different settings.xml with the system property tycho.testSettings.)

Debugging Tycho

In order to debug Tycho plugins inside Eclipse:

  1. Get Tycho sources in Eclipse
  2. Create/get a project that highlights the bug
  3. Run the project with mvnDebug clean install
  4. Go into your Eclipse, use Debug > Remote Java Application, select port 8000

Advanced Topics

Writing integration tests

The hardest part for writing Tycho integration tests is the naming. While names are mostly important for readability, there were also cases where the ID "feature" was used multiple times and hence a test used the build result of a different integration test.

Therefore, here are a few tips for writing good integration tests:

  • Test project name: Although many existing test have a bug number in the name, this is not the recommended naming scheme. Since integration test can take some time to execute, it may be a good idea to test related things in one test.
    So name the test projects in a way that they can be found, and that related tests are sorted next to each other, e.g. in the form <component>.<aspect>.
  • Package: Should be org.eclipse.tycho.test.<component> (without the aspect so that we don't get an excessive number of packages)
  • Test project groupIds: Should be tycho-its-project.<component>.<aspect> plus a segment for the reactor in case of multi-reactor tests. The groupId is particularly important if the test project is installed to the local Maven repository. (Avoid install; use verify if possible.)
  • Test project artifactIds: Have to be the same as the ID of the feature/bundle; need to start with something unique, e.g. the first letters of each segment of the project name.

If you have integration tests under your local sub-module (like tycho-eclipserun-plugin from tycho-extras) then you need to:

  • Build tycho using "bootstrap.sh"
  • Build tycho-extras using "mvn install -Dmaven.repo.local=/tmp/tycho-bootstrap.localrepo"
  • Run you integration test "mvn integration-test -Pits -Dtycho-snapshots-url=file:/tmp/tycho-bootstrap.localrepo"

Building Tycho against a locally built version of p2

Tycho makes heavy use of p2 functionality. Therefore it may be useful to try out patches to p2 without waiting for a new p2 release, or even just the next nightly build. With the following steps it is possible to build Tycho against a locally built version of p2.

  1. Get the p2 sources (see p2 project information)
  2. Make changes in the p2 sources
  3. Build the changed p2 bundles individually with mvn clean install -Pbuild-individual-bundles (see Equinox/p2/Build for more information)
  4. Build at least the Tycho module tycho-bundles-external with mvn clean install - you should see a warning that the locally built p2 bundles have been used.

Then the locally built Tycho SNAPSHOT includes the patched p2 version.

Note: Tycho always allows references to locally built artifacts, even if they are not part of the target platform. Therefore you may want to clear the list of locally built artifacts (in the local Maven repository in .meta/p2-local-metadata.properties) after you have finished your trials with the patched p2 version.

Updating the Equinox and JDT dependencies of Tycho

Tycho has Maven dependencies to Equinox and JDT, so these artifact need to be available in a Maven repository. Currently, the authors don't provide these artifacts in Maven central, so we deploy them ourselves (with the groupId org.eclipse.tycho). See tycho-releng/pom.xml for the technical details on how this is done.

If we want to use a new version of these dependencies in a Tycho snapshot, we can also deploy snapshot versions of these dependencies alongside with the Tycho snapshots. This is how this is done:

  1. Update the p2 repository in tycho-releng/pom.xml
  2. Update the versions in the parent POM so that they match the versions available in the p2 repository. Add the -SNAPSHOT suffix to the Maven version properties.
  3. Commit and upload the change to Gerrit. The Gerrit build will fail with a dependency resolution error.
  4. Trigger the job tycho-deploy-dependencies and make it build the proposed change
  5. Re-trigger the voter job for the Gerrit change. The build should now pass.