I have a bunch of Eclipse-based plugins that I have been migrating to Maven/Tycho. Most of these plugins depend on separate libraries that I now manage through Maven, rather than muddle around with .jar files.
The most cumbersome part of my current setup is due to the apparent inability of Tycho to process Maven-only (i.e. non-OSGi) artifacts. My current setup works like this:
In the
pom.xmlof each Eclipse plugin I issue anunpackgoal tomaven-dependency-pluginduring theinitializephase. This unpacks the artifacts that I specify to a separatetarget/dependenciesdirectory.The
target/dependenciesdirectory is added as an output directory inbuild.properties, so that Tycho can add it to the classpath when compiling:source.. = src/main/java/ output.. = target/classes/ output.. = target/dependencies/The
target/dependenciesdirectory is added to theBundle-ClassPathlibrary inMETA-INF/MANIFEST.MF.
These settings allow the compile Maven directive to compile the plugin. Importing the project from VCS and manually specifying the target/dependencies directory as a class folder in Eclipse allows said IDE to also compile the plugin.
Unfortunately this is a rather cumbersome solution for a few reasons:
Configuring the
maven-dependency-pluginrequires listing all artifacts that should be unpacked. One could useunpack-dependenciesinstead ofunpack, but that would also unpack all OSGi dependencies - having half of Eclipse unpacked in each project directory is not my idea of fun...Adding the class folder in Eclipse requires Maven
initializeto be run once, so that thetarget/dependenciesdirectory is created.There is no source connection between the pure Maven projects and their depending Tycho projects in Eclipse. For a change to propagate from a Maven project to an Tycho project, so that e.g. Eclipse may show a potential compilation problem, one has to
mvn installthe Maven project and then runmvn clean initializein the Tycho project to remove the previously unpacked dependencies and pull in the current set. Then you have to refresh the Eclipse project and hope that Eclipse does the right thing.In the same vein, viewing the source of a dependency from a Tycho project will not show the primary source file, but rather whatever is available in
target/dependencies- quite possibly just a.classfile.
I am thinking that there must be a more reasonable way to go about this - something that would allow Eclipse and Maven projects to integrate more tightly.
So, what am I missing? What is the recommended setup for this use case? Is there a better alternative? Preferably something that would not require setting a bunch of Nexus and/or p2 repositories?