使用maven依赖项和tycho pomConsider选项

时间:2016-12-18 23:18:00

标签: maven eclipse-plugin osgi pom.xml tycho

我尝试使用来自两个存储库的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>

该项目包含一个父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.genstarpom.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>

(2)需要 p2 maven 依赖项的eclipse-plugin pom.xml使用tycho {{ummisco.gaml.extensions.genstar <pomDependencies>consider</pomDependencies> 1}}选项。

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

MANIFEST.MF的{​​{1}}定义如下:

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" 进入mvn clean install时,似乎tycho下载并识别p2中定义的依赖项(例如ummisco.gaml.extensions.parent),并在pom.xml中定义({{1 OSGI包),但这些包的传递依赖性未得到解决。

msi.gama.core

我验证了OSGI Bundle core, spll,gospl, spin清单的传递依赖关系(使用[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] ),看起来是正确的,清单包含 Import-Package 中的依赖关系声明,比如 org.math.R ,你可以在这里看到:

core 1.0.0

我真的不明白为什么tycho使用pom.xml依赖关系不会自动解决传递依赖关系...如果tycho在eclipse-plugin MANIFEST中识别出核心,spll,spin等包,为什么不下载 core,spll,spin,gospl OSGI包的传递依赖性?

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

更新

repository之后,我尝试制作两个项目:

  • mvn dependency:tree将所有依赖项捆绑到一个大罐子里
  • 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 maven-bundle为依据

当我在GUI模式下编译时,Intelij Idea发现了不同的依赖类,但是当我运行tycho-bundle时,我找不到我的maven项目,这真的很奇怪......我不明白问题出在哪里。

您可以找到the archive of the project heremaven-bundle mvn install进入mvn clean install文件夹,然后pom.xml /maven-bundle/进入mvn clean install夹。

0 个答案:

没有答案