Transitive dependencies not resolved with maven dependency and tycho pomConsider option
Asked Answered
G

0

6

I try to create an eclipse plugin using OSGI dependencies from two repositories, one with maven dependencies, and one with p2 dependencies :

<repositories>
<repository>
  <snapshots>
      <enabled>true</enabled>
  </snapshots>
  <id>bintray-anrgenstar-genstar-packages</id>
  <name>bintray</name>
  <url>http://dl.bintray.com/anrgenstar/genstar-packages</url>
  </repository>
</repositories>

<repository>
    <id>gama</id>
    <name>GAMA Snapshots</name>
    <url>http://gama.unthinkingdepths.fr</url>
    <layout>p2</layout>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

The project contain one parent pom.xml into ummisco.gaml.extensions.parent, which build the eclipse plugin ummisco.gaml.extensions.genstar :

  • (1) ummisco.gaml.extensions.parent
    • pom.xml
  • (2) ummisco.gaml.extensions.genstar
    • pom.xml
    • src/...
    • META-INF/MANIFEST.MF

(1) The ummisco.gaml.extensions.genstar parent pom.xml define the module <module>../ummisco.gaml.extensions.genstar</module> to build and call the Tycho maven plugin :

<modelVersion>4.0.0</modelVersion>
    <groupId>ummisco.gaml.extensions</groupId>
    <artifactId>ummisco.gaml.extensions.parent</artifactId>
    <version>1.7.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>../ummisco.gaml.extensions.genstar</module>
    </modules>
    <properties>
        <p2-maven.version>1.2.0-SNAPSHOT</p2-maven.version>
            <tycho.version>0.26.0</tycho.version>
        <project.version>1.7.0-SNAPSHOT</project.version>
    </properties>

    <repositories>
        <repository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>eclipse-mars</id>
            <url>http://download.eclipse.org/releases/mars</url>
            <layout>p2</layout>
        </repository>
        <repository>
            <id>eclipse-elk</id>
            <url>http://build.eclipse.org/modeling/elk/updates/nightly/</url>
            <layout>p2</layout>
        </repository>
        <repository>
            <id>eclipse-graphiti</id>
            <url>http://download.eclipse.org/graphiti/updates/milestones/</url>
            <layout>p2</layout>
        </repository>
        <repository>
            <id>gama</id>
            <name>GAMA Snapshots</name>
            <url>http://gama.unthinkingdepths.fr</url>
            <layout>p2</layout>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-director-plugin</artifactId>
                <version>${tycho.version}</version>
            </plugin>
        </plugins>
    </build>
</project>

(2) The eclipse-plugin pom.xml of ummisco.gaml.extensions.genstar which need p2 and maven dependencies to work use the tycho <pomDependencies>consider</pomDependencies> option.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>ummisco.gaml.extensions.genstar</groupId>
  <artifactId>ummisco.gaml.extensions.genstar</artifactId>
  <packaging>eclipse-plugin</packaging>
  <parent>
    <groupId>ummisco.gaml.extensions</groupId>
    <artifactId>ummisco.gaml.extensions.parent</artifactId>
    <version>1.7.0-SNAPSHOT</version>
    <relativePath>../ummisco.gaml.extensions.parent/</relativePath>
  </parent>

   <dependencies>
    <dependency>
        <groupId>genstar.core</groupId>
        <artifactId>core</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>genstar.spll</groupId>
        <artifactId>spll</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>genstar.spin</groupId>
        <artifactId>spin</artifactId>
        <version>1.0</version>
    </dependency>
      <dependency>
        <groupId>genstar.gospl</groupId>
        <artifactId>gospl</artifactId>
        <version>1.0</version>
    </dependency>
</dependencies>

    <repositories>
        <repository>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
          <id>bintray-anrgenstar-genstar-packages</id>
          <name>bintray</name>
          <url>http://dl.bintray.com/anrgenstar/genstar-packages</url>
          </repository>
    </repositories>

  <build>
    <plugins>
    <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho.version}</version>
        <configuration>
         <resolver>p2</resolver>
         <pomDependencies>consider</pomDependencies>
        </configuration>
    </plugin>
    </plugins> 
  </build>
</project>

The MANIFEST.MF for this eclipse-plugin is defined like that :

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Genstar
Bundle-SymbolicName: ummisco.gaml.extensions.genstar;singleton:=true
Bundle-Version: 1.7.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: msi.gama.core, core, gspl, spin, spll,
 javax.xml;bundle-version="1.3.4"

When i try to mvn clean install into ummisco.gaml.extensions.parent it seems that tycho download and recognize the dependencies defined in p2 (msi.gama.core for example), and defined in pom.xml (core, spll,gospl, spin OSGI bundle), but transitive dependencies of these bundles are not resolved.

[INFO] Fetching p2.index from http://gama.unthinkingdepths.fr/ (172B)
[INFO] Adding repository http://gama.unthinkingdepths.fr
[INFO] Resolving dependencies of MavenProject: ummisco.gaml.extensions.genstar:ummisco.gaml.extensions.genstar:1.7.0-SNAPSHOT @ /home/reyman/Projets/genstar-gama-plugin/ummisco.gaml.extensions.genstar/pom.xml
[INFO] {osgi.os=linux, osgi.ws=gtk, org.eclipse.update.install.features=true, osgi.arch=x86_64}
[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: ummisco.gaml.extensions.genstar 1.7.0.qualifier
[ERROR]   Missing requirement: core 1.0.0 requires 'package org.math.R 0.0.0' but it could not be found
[ERROR]   Cannot satisfy dependency: ummisco.gaml.extensions.genstar 1.7.0.qualifier depends on: bundle core 0.0.0
[ERROR] 

I verify the transitive dependencies of the OSGI Bundle core 1.0.0 manifest (using mvn dependency:tree) and it seems correct, the manifest contain the declaration of dependencies in Import-Package, like org.math.R as you can see here :

Manifest-Version: 1.0
Bnd-LastModified: 1481896487741
Build-Jdk: 1.8.0_101
Built-By: reyman
Bundle-ManifestVersion: 2
Bundle-Name: core
Bundle-SymbolicName: core
Bundle-Version: 1.0
Created-By: Apache Maven Bundle Plugin
Export-Package: core.configuration;version="1.0.0";uses:="com.thoughtw
 orks.xstream,core.metamodel,core.metamodel.pop,core.metamodel.pop.io"
 ,core.metamodel;version="1.0.0",core.metamodel.geo;version="1.0.0";us
 es:="com.vividsolutions.jts.geom,core.metamodel",core.metamodel.geo.i
 o;version="1.0.0";uses:="com.vividsolutions.jts.geom,core.metamodel.g
 eo",core.metamodel.pop;version="1.0.0";uses:="com.vividsolutions.jts.
 geom,core.metamodel,core.metamodel.geo,core.util.data",core.metamodel
 .pop.io;version="1.0.0",core.util;version="1.0.0";uses:="org.apache.l
 ogging.log4j",core.util.R;version="1.0.0";uses:="org.math.R",core.uti
 l.data;version="1.0.0";uses:="core.util.excpetion",core.util.excpetio
 n;version="1.0.0",core.util.random;version="1.0.0",core.util.random.r
 oulette;version="1.0.0",core.util.stats;version="1.0.0"
Import-Package: com.thoughtworks.xstream;version="[1.4,2)",com.thought
 works.xstream.converters;version="[1.4,2)",com.thoughtworks.xstream.c
 onverters.extended;version="[1.4,2)",com.thoughtworks.xstream.io;vers
 ion="[1.4,2)",com.thoughtworks.xstream.io.xml;version="[1.4,2)",com.t
 houghtworks.xstream.mapper;version="[1.4,2)",com.vividsolutions.jts.g
 eom,core.metamodel;version="[1.0,2)",core.metamodel.geo;version="[1.0
 ,2)",core.metamodel.pop;version="[1.0,2)",core.metamodel.pop.io;versi
 on="[1.0,2)",core.util.data;version="[1.0,2)",core.util.excpetion;ver
 sion="[1.0,2)",core.util.random;version="[1.0,2)",org.apache.logging.
 log4j;version="[2.7,3)",org.math.R,org.rosuda.REngine,org.rosuda.REng
 ine.Rserve
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007

I really don't understand why the transitive dependencies are not automaticly resolved by tycho using the pom.xml dependency ... If tycho recognized the core, spll, spin, etc. package in the eclipse-plugin MANIFEST, why the transitive dependencies of core, spll, spin, gospl OSGI bundle are not downloaded ?

Do you think there is a solution for this problem ?

UPDATE

Following this repository i try to make two project :

  • maven-bundle which bundle all dependencies into one big jar
  • tycho-bundle which take this maven-bundle in dependency

Intelij Idea found the different dependency class when i compile in GUI mode, but not my maven project when i run mvn install, it's really really weird... I don't understand where is the problem.

You can find the archive of the project here, you need to mvn clean install pom.xml into /maven-bundle/ folder, then mvn clean install pom.xml into tycho-bundle/ folder.

Gewgaw answered 18/12, 2016 at 23:18 Comment(15)
Hi there, I came here from my other question. I have to admit, that I didn't read the entire post in detail, due to my current lack of time, so apologies if I'm stating something obvious. But: At first glance, the issue sounds familiar to me. You may want to check this limitation: wiki.eclipse.org/Tycho/How_Tos/…. Due to that limitation, what I had to do: Create two separate builds, one for the bundle wrappers, and a second one for Tycho. Hope that helps!Beatrix
I also try to bundle the pom dependency in a tycho p2 site, and, in the other build which point on this local p2 site i never success to get correctly these dependency from MANIFEST.MF.Gewgaw
@Beatrix because i try multiple solution without success, i open bounty for this question if you want. I need a simple example to understand why this doesn't work :(Gewgaw
I can try to compile a reduced example how we're doing those things. However, it'll probably take until the weekend. If you shouldn't hear from me until Sunday, feel free to send me a reminder.Beatrix
Hi, thanks a lot for your help @Beatrix !Gewgaw
Hi @Beatrix i update my question with some new progress i made, but i found another problem. My project compile into my IDE but not with maven, this is really weird. If you have an idea ...Gewgaw
I already started writing our structure together. But it's more than I had originally estimated. Should be done by tomorrow, stay tuned :)Beatrix
Hey there, I managed to create a minimal variant which seems to be working so far. Have a look here: github.com/qqilihq/tycho-maven-example Sorry for being sparingly with comments, time is a little tight currently, but feel free to ask any questions!Beatrix
Thanks @qqilihq, it's a great exemple ! But because i cannot define all dependencies manually (i also need transitive dependencies ...) , i try to generate a p2 site with all transitive dependencies of my project, so after that i can use it directly for plugin building : #41753372Gewgaw
This should actually work just fine; the transitive dependencies should simply be integrated into the created bundles with the given example. At least that's the way we're doing it mostly. In case you want to split out certain dependencies and provide them as stand alone bundle, you'll have to add them as separate entry in 01_bundle_wrappers and adjust the exclusion entries accordingly (we're doing that with the Guava dependencies in the given example).Beatrix
The perfect solution would of course be a fully automated workflow which would convert a dependency and all its transitive dependencies into single OSGi compatible bundles. But such a solution does not exist unfortunately (and if anybody can proof me wrong, I'll be most thankful :) )Beatrix
Thanks @qqilihq, for information, i also found a great plugin in gradle : github.com/diffplug/goomphGewgaw
That sounds really interesting. I would be greatly interested if you manage to set up a working build workflow with that.Beatrix
You can find here my project @Beatrix : github.com/ANRGenstar/gamaplugin I try to make a sample example later :)Gewgaw
Cool, thank you. I'll definitely keep an eye on that!Beatrix

© 2022 - 2024 — McMap. All rights reserved.