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:

  1. in pom.xml of each eclipse plugin issue unpack goal maven-dependency-plugin during initialize phase. unpacks artifacts specify separate target/dependencies directory.

  2. the target/dependencies directory added output directory in build.properties, tycho can add classpath when compiling:

    source.. = src/main/java/ output.. = target/classes/ output.. = target/dependencies/ 
  3. the target/dependencies directory added bundle-classpath library in meta-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-plugin requires listing artifacts should unpacked. 1 could use unpack-dependencies instead of unpack, unpack osgi dependencies - having half of eclipse unpacked in each project directory not idea of fun...

  • adding class folder in eclipse requires maven initialize run once, target/dependencies directory 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 install maven project , run mvn clean initialize in 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 .class file.

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).

  1. for unpacking dependencies, use maven-dependency-plugin place them in target/dependency (see below).
    • 1.1. copy-dependencies needed without unpack.
  2. your source , output same mine.
    • 2.1. yes, mvn has initialize target/dependencies
  3. 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.
  4. 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

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -