java - Handling non-OSGi dependencies when integrating Maven, Tycho and Eclipse -
i have bunch of eclipse-based plugins have been migrating maven/tycho. of these plugins depend on separate libraries manage through maven, rather muddle around .jar files.
the cumbersome part of current setup due apparent inability of tycho process maven-only (i.e. non-osgi) artifacts. current setup works this:
in
pom.xmlof each eclipse plugin issueunpackgoalmaven-dependency-pluginduringinitializephase. unpacks artifacts specify separatetarget/dependenciesdirectory.the
target/dependenciesdirectory added output directory inbuild.properties, tycho can add classpath when compiling:source.. = src/main/java/ output.. = target/classes/ output.. = target/dependencies/the
target/dependenciesdirectory addedbundle-classpathlibrary inmeta-inf/manifest.mf.
these settings allow compile maven directive compile plugin. importing project vcs , manually specifying target/dependencies directory class folder in eclipse allows said ide compile plugin.
unfortunately rather cumbersome solution few reasons:
configuring
maven-dependency-pluginrequires listing artifacts should unpacked. 1 could useunpack-dependenciesinstead ofunpack, unpack osgi dependencies - having half of eclipse unpacked in each project directory not idea of fun...adding class folder in eclipse requires maven
initializerun once,target/dependenciesdirectory created.there no source connection between pure maven projects , depending tycho projects in eclipse. change propagate maven project tycho project, e.g. eclipse may show potential compilation problem, 1 has
mvn installmaven project , runmvn clean initializein tycho project remove unpacked dependencies , pull in current set. have refresh eclipse project , hope eclipse right thing.in same vein, viewing source of dependency tycho project not show primary source file, rather whatever available in
target/dependencies- quite possibly.classfile.
i thinking there must more reasonable way go - allow eclipse , maven projects integrate more tightly.
so, missing? recommended setup use case? there better alternative? preferably not require setting bunch of nexus and/or p2 repositories?
it seems apply similar strategies. however, use nexus mixed repository (having both maven , p2).
- for unpacking dependencies, use maven-dependency-plugin place them in target/dependency (see below).
- 1.1. copy-dependencies needed without unpack.
- your source , output same mine.
- 2.1. yes, mvn has initialize target/dependencies
- i include required jars in manifest, because 1 retrieve many unnecessary jars.
- 3.1. manually select relevant jars.
- 3.2. yes, if non-eclipse-managed (maven) projects change (outside of workspace), have run mvn build update them.
- 3.3. key making work, to:
- 3.3.1 deploy maven , eclipse projects (snapshot) repository. use http://www.sonatype.org/nexus/ . thus, when run maven, looks @ nexus repository updates of both maven , eclipse projects.
- some other notes, may obvious:
- 4.1. pom.xml file should contain non-eclipse jars dependencies. (the tycho plugin handles eclipse dependencies, should found in (nexus) repository.)
- 4.2. add dependent jars runtime in eclipse (by editing plugin.xml runtime)
maven plugin:
<plugin> <!-- copy non-ecipse plugins target/dependency may referenced runtime use. --> <artifactid>maven-dependency-plugin</artifactid> <version>2.1</version> <executions> <execution> <id>copy-dependencies</id> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <excludegroupids>org.xxx</excludegroupids> </configuration> </execution> <execution> <id>classpath</id> <goals> <goal>build-classpath</goal> </goals> <configuration> <fileseparator>/</fileseparator> <prefix>target/dependency</prefix> <outputfile>${project.build.directory}/classpath.txt </outputfile> </configuration> </execution> </executions> </plugin> example build.properties
bin.includes = meta-inf/, target/classes/, plugin.xml, target/dependency/mongo-java-driver-2.11.3.jar example manifest (only subset of jars):
bundle-classpath: ., target/classes/, target/dependency/mongo-java-driver-2.11.3.jar
Comments
Post a Comment