This example project shows how to develop and build an Eclipse based application using Tycho.
It shows how to:
- build a product with Tycho
- use a target platform file both inside Tycho and Eclipse
- create a structure that can be used on multiple operation system (e.g. my OS is Windows, but this project is build by Travis using Linux)
- use plain Maven dependencies
Content of this ReadMe:
- de.slothsoft.example.build - parent of the reactor
- de.slothsoft.example - the plug-in with the usable code
- de.slothsoft.example.it - the integration tests for above plug-in
- de.slothsoft.example.feature - a feature for a feature-based product
- de.slothsoft.example.product - the product file to start and build an application
- maven-p2 - the P2 repository for Maven dependencies
This project is the parent of the reactor and contains common resources and configurations.
- platform.target - all the dependencies in one handy file; can be used by both Tycho and Eclipse
- pom.xml - most of the Maven and Tycho configuration
- README.md - a landing page for the repository
This project is the plug-in with the usable code. It just contains the Eclipse template for a new application and the template for a view.
This project tests the project de.slothsoft.example
. In this example, it's tested that the view ExampleView
can be opened without problems.
This project contains a feature for a feature-based product.
This project has the product file to start build an application from Eclipse and build it from Tycho.
This project converts plain Maven dependencies into a P2 repository and is able to start and stop said repository. It can handle JARs with and without OSGi information in their Manifest.MF.
Check out the awesome p2-maven-plugin to learn more.
To start this project in your Eclipse, do:
- Clone this repository
- Call
mvn install -Pstart
on maven-p2/pom.xml to start a P2 repository locally - To start the application from Eclipse do the following:
- Open the file platform.target and click on "Set as Active Target Platform"
- de.slothsoft.example.product/ExampleApp.product and click on "1. Synchronize" and then "2. Launch Eclipse Application"
- To build the application with Tycho
- Run
mvn clean install
on the repository root - Or in Eclipse right click on the pom.xml and use "Run as..." → "Maven install"
- The resulting EXE file is in de.slothsoft.example.product/target/products/de.slothsoft.example.product-<time>-<os>.zip and / or the folder next to the ZIP file
- Run
- when finished, call
mvn package -Pstop
to stop the P2 repository
To use this example as a template for your Eclipse based application you need to do the following:
- check out this project (or use the button "Use this template" in GitHub)
- rename my IDs to yours
- "de.slothsoft" to your company's domain (including packages)
- "example" to your project's name (the same for capitalized "Example")
- "Slothsoft" to your company's name
The Eclipse version is set inside the platform.target. Just change the repository location to your wanted Eclipse version and adjust the versions of the features (or use "0.0.0" to get the latest version).
The file platform.target should be able to accommodate every OS you could open it with. The pom.xml file next to it however has information about the OS this application gets build for. Edit the <environments>
tag of the target-platform-configuration
plug-in to change this build to your liking, or add more environments to build the application for multiple OS.
The file pom.xml has a property tycho.version
that can be changed easily.
The Java version is defined inside the MANIFEST.MF for each plug-in (including the IT project).
I followed the tutorial for the Maven plug-in p2-maven-plugin. Basically, the following is done:
- call
mvn install -Pstart
on maven-p2/pom.xml to create a P2 repository and then start it locally - now the platform.target can access "http://localhost:8080/site/"
- when finished, call
mvn package -Pstop
ormvn jetty:stop
to stop the P2 repository
The entire configuration is contained in maven-p2/.
If you don't need the feature, you can remove it like this:
- Delete the folder maven-p2/ from the repository
- Remove the location "http://localhost:8080/site/" from platform.target
- Remove the "before_install" and "after_script" part of the Travis configuration file .travis.yml
Open the file maven-p2/pom.xml and configure the artifacts of the p2-maven-plugin
. I'd advise to only add one version for each artifact and use "0.0.0" in the target platform.
The official release notes of Tycho 0.24 will show you how it's done.
This official tutorial shows how to release a Tycho project.
(All open issues can be found here.)
This project is licensed under the MIT License - see the MIT license for details.