无法使用Maven依赖项和tycho pomConsider选项解决传递性依赖项

rey*_*n64 6 osgi eclipse-plugin pom.xml tycho maven

我尝试使用来自两个存储库的OSGI依赖关系创建一个eclipse插件,其中一个具有maven依赖关系,而另一个具有p2依赖关系:

<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>
Run Code Online (Sandbox Code Playgroud)

该项目包含一个父pom.xml ummisco.gaml.extensions.parent,用于构建eclipse插件ummisco.gaml.extensions.genstar

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

(1)ummisco.gaml.extensions.genstar父级pom.xml定义<module>../ummisco.gaml.extensions.genstar</module>要构建的模块 并调用Tycho maven插件:

<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>
Run Code Online (Sandbox Code Playgroud)

(2)eclipse-plugin pom.xmlummisco.gaml.extensions.genstar,其需要P2Maven的依赖关系,工作中使用的第谷<pomDependencies>consider</pomDependencies>选项。

<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>
Run Code Online (Sandbox Code Playgroud)

MANIFEST.MF这个eclipse-plugin定义这样的:

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"
Run Code Online (Sandbox Code Playgroud)

当我尝试mvn clean install进入ummisco.gaml.extensions.parent时,tycho似乎下载并识别了p2中定义的依赖关系(msi.gama.core例如)和pom.xml(core, spll,gospl, spinOSGI捆绑软件)中定义的依赖关系,但是这些捆绑软件的传递性依赖关系无法解决。

[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] 
Run Code Online (Sandbox Code Playgroud)

我验证了OSGI Bundle core 1.0.0清单的可传递依赖关系(使用mvn dependency:tree),它似乎是正确的,该清单包含Import-Package中的依赖关系声明,如org.math.R,您可以在这里看到:

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
Run Code Online (Sandbox Code Playgroud)

我真的不明白为什么tycho无法使用pom.xml依赖关系自动解决传递依赖关系...如果tycho识别了eclipse-plugin MANIFEST中core,spl,spin等软件包,为什么会传递依赖关系核心,spl,spin,gospl OSGI软件包是否未下载?

您认为这个问题有解决方案吗?

更新

在此存储库之后,我尝试创建两个项目:

  • maven-bundle 将所有依赖项捆绑到一个大罐子中
  • tycho-bundlemaven-bundle依赖于此

当我在GUI模式下编译时,Intellij Idea发现了不同的依赖关系类,但是当我运行时却没有找到我的Maven项目mvn install,这真的很奇怪……我不知道问题出在哪里。

您可以在此处找到项目的存档,需要将其mvn clean install pom.xml放入/maven-bundle/文件夹,然后再mvn clean install pom.xml放入tycho-bundle/文件夹。