我正在尝试使用tycho来构建我的蚀我的plugin。
我的软件包 com.mycompany.math 需要 org.apache.commons.math-1.2.0 ,安装在我的p2-repository中。依赖项在 org.mycompany.math.math 的subtest.mf中定义。
Require-Bundle: org.apache.commons.math;bundle-version="1.2.0",
在构建过程中,我得到了org.apache.commons.math类无法解决的错误消息。在构建开始之前,Maven/Tycho下载了2.1.0-version。因此,我的问题是,当我在清单中定义的Maven/Tycho下载2.1.0为什么我使用1.2.0。
您可以在我的父pom.xml中看到我定义了三个p2 repository的。最后一个包含我所需的1.2.0 version。
我的父母pom.xml:
<project...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>com.mycompany.build</artifactId>
<version>3.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Build</name>
<description>Parent POM for full builds</description>
<modules>
<!-- my modules -->
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tycho-version>0.16.0</tycho-version>
</properties>
<repositories>
<!-- configure p2 repository to resolve against -->
<repository>
<id>juno</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/juno/</url>
</repository>
<repository>
<id>orbit</id>
<layout>p2</layout>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/S20121021123453/repository/</url>
</repository>
<repository> <-- CONTAINS ORG.APACHE.COMMONS.MATH-1.2.0 !
<id>comp</id>
<layout>p2</layout>
<url>http:our-adress.com/p2/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<pomDependencies>consider</pomDependencies>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</dependencyManagement>
和我的 com.com.pan.math pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>com.mycompany.math</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Math</name>
<packaging>eclipse-plugin</packaging>
<parent>
<groupId>com.mycompany</groupId>
<artifactId>com.mycompany.build</artifactId>
<version>3.1.0-SNAPSHOT</version>
<relativePath>../com.mycompany.build</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>commons-math</groupId>
<artifactId>commons-math</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
问题是您的Require-Bundle
语句太笼统了:使用Require-Bundle: org.apache.commons.math;bundle-version="1.2.0"
,您实际上指定了版本1.2.0 或任何以后版本中的数学捆绑包。
您应该指定只需1.2.0或兼容版本。可以使用Require-Bundle: org.apache.commons.math;bundle-version="[1.2.0,2.0.0)"
来完成。该语句可防止您的捆绑包与运行时数学捆绑包的(显然不兼容)2.1版本(这也很重要!),并且可能还会解决您的构建问题。
tycho仍然可以在目标平台中存在此类版本(即,在您的情况下,任何已配置的P2存储库或POM依赖关系中的任何一个版本)仍然可以解决用于构建的数学捆绑包的较高1.x版本。如果是这种情况,但是您想强制执行1.2版本在构建中使用,则需要控制目标平台的内容。(Maven <dependencyManagement>
还不够,因为它对您配置的P2存储库没有影响。)您可以通过在Tycho的目标平台配置中指定过滤器来执行此操作:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<filters>
<filter>
<type>eclipse-plugin</type>
<id>org.apache.commons.math</id>
<restrictTo>
<version>1.2.0</version>
</restrictTo>
</filter>
</filters>
</configuration>
</plugin>