The eclipse is the only good tool to develop eclipse plugins, rich client platform (RCP) applications i guess. However, when it comes to build automation, or continuous build/integration/delivery, what will be the option for building eclipse plugins/rcp application? I remember I once tried ant to build eclipse based application (eclipse product) for different platforms. It was not a happy experience.
Fortunately, people have developed maven plugins to build various eclipse related artifacts (plugin jars, eclipse product zips for different platforms and etc). This maven plugin is called Tycho (http://eclipse.org/tycho/).
There are already a few tutorials on how to use tycho to build eclipse plugins or other eclipse artifacts. For example, Lars Vogel's tutorial is quite in detail. So I am not going to put more effort on creating a basic tutorial.
I want to solve a problem I encountered during the process of converting a eclipse plugin project to maven project. The problem is:
Sometimes, an eclipse plugin project depends on other non-eclipse plugin projects or some third party libs. How to deal with the maven dependency and the plugin dependency and declare them in the maven pom files is a bit intriguing in the beginning.
The further research reveals a solution. Basically, eclipse plugin uses the its own mechanism to define library or bundle dependency, i.e. through MANIFEST.MF. Its required bundle (Requre-Bundle) needs to be in the p2 repository, which is a different layout of maven repository.
So the idea is to have two maven projects:
- project1: a project that contains all the dependencies required by the project2
- project2: a project that depends on project1. It also has the tycho plugin configured.
<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.4.0</version> <extensions>true</extensions> <!-- the following instructions build a simple set of public/private classes into an OSGi bundle --> <configuration> <manifestLocation>META-INF</manifestLocation> <instructions> <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName> <Bundle-Version>${bundle.version}</Bundle-Version> <!-- assume public classes are in the top package, and private classes are under ".impl" --> <Export-Package>!*.impl,com.mytechtip.*</Export-Package> <!-- embed compile/runtime dependencies using path that matches the copied dependency folder --> <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency> <Embed-Directory>jars</Embed-Directory> <Embed-StripGroup>true</Embed-StripGroup> <Embed-Transitive>true</Embed-Transitive> <Import-Package></Import-Package> </instructions> </configuration> </plugin>
For more information about "maven-bundle-plugin", have a look at http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
The following link has an example to illustrate the idea: http://wiki.eclipse.org/Tycho/How_Tos/Dependency_on_pom-first_artifacts.

No comments:
Post a Comment