A product (a branded Eclipse application, or one that is launched from eclipse -application
from the command line) can also be built with Tycho using the eclipse-repository
packaging type. To do this, the app project needs to be built with Tycho and made available in the feature, and a new project for the product needs to be created.
com.packtpub.e4.application
project under the com.packtpub.e4.parent project
.<module>com.packtpub.e4.application</module>
to the parent pom.xml
file.pom.xml
file from the clock
plugin to the application
project.artifactId
to com.packtpub.e4.application
.pom.xml
file will look like this:<?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> <groupId>com.packtpub.e4</groupId> <artifactId>com.packtpub.e4.parent</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> <groupId>com.packtpub.e4</groupId> <artifactId>com.packtpub.e4.application</artifactId> <!-- version>1.0.0-SNAPSHOT</version --> <packaging>eclipse-plugin</packaging> </project>
com.packtpub.e4.feature/feature.xml
to add the reference to the application plug-in:<feature> ... <pluginid="com.packtpub.e4.application" download- size="0" install-size="0" version="0.0.0" unpack="false"/> </feature>
mvn clean package
from the parent, and the build should complete with the application plug-in.com.packtpub.e4.product
. Move the com.packtpub.e4.application.product
file from the com.pactkpub.e4.application
project into the product project.com.packtpub.e4.application/pom.xml
into the com.packtpub.e4.product
project, and modify the artifactId
to be com.packtpub.e4.product
. Change the packaging
type to eclipse-repository
.pom.xml
file with <module>com.packtpub.e4.product</module>
.mvn clean package
from the parent, and it will complain with an error:[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-publisher- plugin:0.18.0:publish-products (default-publish-products) on project com.packtpub.e4.application: The product file com.packtpub.e4.application.product does not contain the mandatory attribute 'uid' -> [Help 1]
com.packtpub.e4.application/com.packtpub.e4.application.product
and add uid
as a copy of the id
attribute.org.eclipse.rcp
and com.packtpub.e4.feature
features, removing the plugins element:<product name="com.packtpub.e4.application" uid="com.packtpub.e4.application.product" id="com.packtpub.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true"> <features> <feature id="com.packtpub.e4.feature" version="0.0.0"/> <feature id="org.eclipse.rcp" version="0.0.0"/> </features> <plugins/> ... </product>
mvn package
from the parent again, and the build should succeed. The com.packtpub.e4.product/target/repository
now contains the product for the target platform you're running on.pom.xml
file, or the parent pom.xml
:<plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <environments> <environment> <os>win32</os> <ws>win32</ws> <arch>x86_64</arch> <!--arch>x86</arch--> </environment> <environment> <os>linux</os> <ws>gtk</ws> <arch>x86_64</arch> <!--arch>x86</arch--> </environment> <environment> <os>macosx</os> <ws>cocoa</ws> <arch>x86_64</arch> <!--arch>x86</arch--> </environment> </environments> </configuration> </plugin>
<arch>x86</arch>
instead.p2
repository for them, add the materialize-products
goal to the com.packtpub.e4.application/pom.xml
file:<build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-p2-director-plugin</artifactId> <version>${tycho-version}</version> <configuration> <formats> <win32>zip</win32> <linux>tar.gz</linux> <macosx>tar.gz</macosx> </formats> </configuration> <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>
mvn clean package
and the build will create com.packtpub.e4.application/target/products/os/ws/arch
, as well as creating archives (ZIP files) of them.eclipse -consoleLog
):java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
eclipse -application
. Add this to the com.packtpub.e4.application.product
file:<configurations> <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4"/> <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2"/> <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2"/> <!-- for 'dropins' directory support --> <!-- plugin id="org.eclipse.equinox.p2.reconciler.dropins" autoStart="true" startLevel="4"/ --> <plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1"/> <!-- disable old update manager --> <property name="org.eclipse.update.reconcile" value="false"/> <!-- for 'new' update manager support --> <!-- plugin id="org.eclipse.update.configurator" autoStart="true" startLevel="4"/ --> </configurations>
mvn clean package
and try running the product again. This time it should succeed.Eclipse applications are built and made available as a p2
repository or as archived downloads. The p2
repository allows the product to be updated using the standard update mechanisms; this is how updates from 4.2.0 to 4.2.1 to 4.2.2 occur. The archives are used to provide direct download links, as are found at http://download.eclipse.org for the standard packages.
For RCP-based applications, it is easier to build on the RCP feature, which provides the necessary platform-specific fragments for SWT and file-systems. Although building a product based on plug-ins is possible, almost all RCP and SDK applications are built upon either the RCP feature or the IDE feature respectively.
For Eclipse to launch successfully, a number of plug-ins need to be started when the application starts. This is controlled using the config.ini
file, which in turn is read by simpleconfigurator
, so this needs to be started at the started at the launch of the runtime. In addition to this, the E4
platform requires Declarative Services (DS) to be installed and started, as well as the runtime bundle.
By decomposing the projects into a feature, and then having the same feature used for both the SWTBot and product definitions, it becomes the de-facto place for adding new content. Then these changes to the feature are automatically visible in the product, the automated tests, and in the update site.
Sometimes, it is necessary to depend on components that have been built by ordinary Maven jobs. Although it's not possible to mix and match Tycho and ordinary Maven reactor builds in the same build, it is possible to allow Tycho to resolve Maven components as part of the target platform.
Since ordinary Maven dependencies are represented by the <dependencies>
tag, it is possible to define additional dependencies that can be consumed or used by Tycho builds. Normally Tycho won't use this information, but to allow Tycho to resolve those and make them available as OSGi bundles for the purposes of the Eclipse build, modify the configuration for target-platform-configuration
and add the line <pomDependencies>consider</pomDependencies>
to the <configuration>
element.
Note that only OSGi bundles are added to the dependencies list; others are silently ignored.