Maven/Tycho使用了错误的捆绑包版本

Maven/Tycho使用了错误的捆绑包版本,maven,build,eclipse-rcp,tycho,Maven,Build,Eclipse Rcp,Tycho,我正在尝试使用tycho构建我的eclipse插件 我的包com.mycompany.math需要org.apache.commons.math-1.2.0,它安装在我的p2存储库中。 依赖项在org.mycompany.math的MANIFEST.MF中定义: 在构建过程中,我收到一条错误消息,org.apache.commons.math-classes无法解析。 在构建开始之前,maven/tycho下载了2.1.0版本。 所以,我的问题是,当我在MANIFEST.MF中定义使用1.2.0

我正在尝试使用tycho构建我的eclipse插件

我的包com.mycompany.math需要org.apache.commons.math-1.2.0,它安装在我的p2存储库中。 依赖项在org.mycompany.math的MANIFEST.MF中定义:

在构建过程中,我收到一条错误消息,org.apache.commons.math-classes无法解析。 在构建开始之前,maven/tycho下载了2.1.0版本。 所以,我的问题是,当我在MANIFEST.MF中定义使用1.2.0时,为什么maven/tycho下载了2.1.0

您可以在我的父pom.xml中看到,我定义了三个p2存储库。最后一个,包含我所需的1.2.0版本

我的父母pom.xml:


4.0.0
com.mycompany
com.mycompany.build
3.1.0-快照
聚甲醛
建造
完整构建的父POM
UTF-8
0.16.0
朱诺
p2
http://download.eclipse.org/releases/juno/
轨道
p2
http://download.eclipse.org/tools/orbit/downloads/drops/S20121021123453/repository/

问题是您的
Require Bundle
语句过于笼统: 使用
requirebundle:org.apache.commons.math;bundle version=“1.2.0”
您实际上指定需要版本1.2.0或任何更高版本的数学bundle

您应该指定只需要1.2.0或兼容版本。这可以通过
requirebundle:org.apache.commons.math;bundle version=“[1.2.0,2.0.0]”
。此语句可防止在运行时将bundle连接到数学bundle的(显然不兼容)2.1版本(这一点也很重要!),并且它还可能修复生成问题

Tycho可能仍会针对更高的1.x版本的math bundle进行解析,以进行构建,前提是该版本存在于中(即,在您的情况下,任何配置的p2存储库或POM依赖项中)。如果是这种情况,但您希望强制在构建中使用1.2版本,则需要控制目标平台的内容。(Maven
不够,因为它不会影响您配置的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>

org.eclipse.tycho
目标平台配置
${tycho版本}
eclipse插件
org.apache.commons.math
1.2.0
<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>
<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>
<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>