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/Reference Card"

(Selecting JDK)
(fixed typo: IIRC source bundles get ".source" appended)
Line 218: Line 218:
 
</pre>
 
</pre>
  
For convenience, you can do this only once in your parent POM. A source bundle (with ".test" appended to the Bundle-SymbolicName) will be generated for each module inheriting from this parent which has packaging type eclipse-plugin or eclipse-test-plugin.
+
For convenience, you can do this only once in your parent POM. A source bundle (with ".source" appended to the Bundle-SymbolicName) will be generated for each module inheriting from this parent which has packaging type eclipse-plugin or eclipse-test-plugin.
  
 
To assemble source bundles, at this point you need to create source feature(s) which include the source bundles same as for normal bundles.
 
To assemble source bundles, at this point you need to create source feature(s) which include the source bundles same as for normal bundles.

Revision as of 03:48, 20 July 2011

Enabling tycho

   <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-maven-plugin</artifactId>
      <version>${tycho-version}</version>
      <extensions>true</extensions>
   </plugin>
Note that this is usually defined in the parent POM in under build / plugins

Repository providing the context of the build

Specify a repository to get pre-built pieces from. Multiple repository can be specified. See also target platform section.

   <repository>
      <id>eclipse-indigo</id>
      <layout>p2</layout>
      <url>http://download.eclipse.org/releases/indigo</url>
   </repository>

Target platform providing the context of the build

Use a target platform to get pre-build pieces from. The target platform file can be edited using Eclipse PDE editor.

          <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>${tycho-version}</version>
            <configuration>
              <resolver>p2</resolver>
              <target>
                <artifact>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>${project.artifactId}</artifactId>
                  <version>${project.version}</version>
                  <classifier>TargetFileNameWithoutExtension</classifier>
                </artifact>
              </target>
            </configuration>
          </plugin>

Bundle, Fragments

  <groupId>Some-Group-Id</groupId>
  <artifactId>Bundle-SymbolicName</artifactId>
  <version>Bundle-Version</version>
  <packaging>eclipse-plugin</packaging>

Features

  <groupId>Some-Group-Id</groupId>
  <artifactId>FeatureId</artifactId>
  <version>FeatureVersion</version>
  <packaging>eclipse-feature</packaging>

p2 repositories

  <groupId>Some-Group-Id</groupId>
  <artifactId>RepositoryName</artifactId>
  <version>Version</version>
  <packaging>eclipse-repository</packaging>

Products

  <groupId>Some-Group-Id</groupId>
  <artifactId>RepositoryName</artifactId>
  <version>Version</version>
  <packaging>eclipse-repository</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-p2-director-plugin</artifactId>
        <version>${tycho-version}</version>
        <executions>
          <execution>
            <id>materialize-products</id>
            <goals>
              <goal>materialize-products</goal>
            </goals>
          </execution>
          <execution>
            <id>archive-products</id>
              <goals>
                <goal>archive-products</goal>
              </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Update Site

  <groupId>Some-Group-Id</groupId>
  <artifactId>UpdateSiteName</artifactId>
  <version>Version</version>
  <packaging>eclipse-update-site</packaging>

Test bundles

  <groupId>Some-Group-Id</groupId>
  <artifactId>Bundle-SymbolicName</artifactId>
  <version>Bundle-Version</version>
  <packaging>eclipse-test-plugin</packaging>

Setting up the tests to run

   <plugin>
      <groupId>org.eclipse.tycho</groupId>
         <artifactId>tycho-surefire-plugin</artifactId>
         <version>${tycho-version}</version>
         <configuration>
            <testSuite>Bundle-SymbolicName-of-bundleContaining-Tests</testSuite>
            <testClass>FullyQualifiedNameOfTheTestClass</testClass>
        </configuration>
      </plugin>

Setting VM args

In the configuration section for the test plug-in

           <argLine>-Xmx512m</argLine>

Setting application arguments

In the configuration section for the test plug-in

           <useUIHarness>true</useUIHarness>

Running an application or a product

           <application>EclipseApplicationID</application>
           <product>EclipseProductID</product>

Bundle start level

           <bundleStartLevel>
              <bundle>
                 <id>Bundle-SymbolicName</id>
                 <level>1</level>
                 <autoStart>true</autoStart>
              </bundle>
           </bundleStartLevel>

Selecting JDK

Since version 0.13 tycho-surefire-plugin can use Maven Toolchains to run tests with a specific version of JDK independent from the one Maven is running with.

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-toolchains-plugin</artifactId>
    <version>1.0</version>
    <executions>
      <execution>
        <phase>validate</phase>
        <goals>
          <goal>toolchain</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <toolchains>
        <jdk>
          <version>1.5</version>
          <vendor>sun</vendor>
        </jdk>
      </toolchains>
    </configuration>
  </plugin>

Source Bundles

To generate source bundles, you need to execute goal "plugin-source" of plugin tycho-source-plugin:

  <build>
    <plugins>   
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-source-plugin</artifactId>
        <version>${tycho-version}</version>
        <executions>
          <execution>
            <id>plugin-source</id>
            <goals>
              <goal>plugin-source</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

For convenience, you can do this only once in your parent POM. A source bundle (with ".source" appended to the Bundle-SymbolicName) will be generated for each module inheriting from this parent which has packaging type eclipse-plugin or eclipse-test-plugin.

To assemble source bundles, at this point you need to create source feature(s) which include the source bundles same as for normal bundles.

Generating POM files

mvn org.eclipse.tycho:tycho-pomgenerator-plugin:generate-poms -DgroupId=<MY.PROJECT>


Putting it all together

Examplary parent POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.eclipse</groupId>
	<artifactId>org.eclipse.equinox.p2-parent</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>pom</packaging>

	<properties>
		<tycho-version>0.12.0</tycho-version>
	</properties>
	<repositories>
		<repository>
			<id>helios</id>
			<layout>p2</layout>
			<url>http://download.eclipse.org/releases/helios</url>
		</repository>
		<repository>
			<id>galileoTest</id>
			<layout>p2</layout>
			<url>http://download.eclipse.org/eclipse/updates/3.6-JUnit-Tests/</url>
		</repository>
	</repositories>

	<build>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-maven-plugin</artifactId>
				<version>${tycho-version}</version>
				<extensions>true</extensions>
			</plugin>

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

Examplary bundle/fragment POM

<?xml version="1.0" encoding="UTF-8"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>org.eclipse.equinox.p2-parent</artifactId>
		<groupId>org.eclipse</groupId>
		<version>0.0.1-SNAPSHOT</version>
		<relativePath>../org.eclipse.equinox.p2-parent</relativePath>
	</parent>
	<groupId>org.eclipse</groupId>
	<artifactId>org.eclipse.equinox.p2.director</artifactId>
	<version>2.0.0.qualifier</version>
	<packaging>eclipse-plugin</packaging>
</project>

Examplary Test bundle POM

<?xml version="1.0" encoding="UTF-8"?>
<project
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>org.eclipse.equinox.p2-parent</artifactId>
		<groupId>org.eclipse</groupId>
		<version>0.0.1-SNAPSHOT</version>
		<relativePath>../org.eclipse.equinox.p2-parent</relativePath>
	</parent>
	<groupId>org.eclipse</groupId>
	<artifactId>org.eclipse.equinox.p2.tests</artifactId>
	<version>1.2.0.qualifier</version>
	<packaging>eclipse-test-plugin</packaging>

	<build>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>maven-osgi-test-plugin</artifactId>
				<configuration>
					<testSuite>org.eclipse.equinox.p2.tests</testSuite>
					<testClass>org.eclipse.equinox.p2.tests.AutomatedTests</testClass>
					<argLine>-Xmx512m</argLine>
					<bundleStartLevel>
						<bundle>
							<id>org.eclipse.equinox.ds</id>
							<level>1</level>
							<autoStart>true</autoStart>
						</bundle>
					</bundleStartLevel>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

Back to the top