Tycho:当通过多模块父母建立时,“无法满足依赖性......”

时间:2012-04-20 10:08:30

标签: maven tycho

我必须构建一个带有Maven / Tycho的Eclipse插件,它与其他第三方有依赖关系。由于Tycho尚不支持嵌入依赖项,因此我将项目拆分为以下两个:

  • A-thirdparty:带有包装'捆绑'的项目,由 maven-bundle-plugin 构建,具有'嵌入 - 依赖'指令,并导出所有插件'A'
  • 所需的软件包
  • A:项目包含'eclipse-plugin',使用tycho-maven-plugin,以及Tycho的目标平台配置插件,pomDependencies设置为consider

当我单独构建它们时(首先是第三方聚合器,然后是项目A本身),一切正常。但是,如果我聚合这两个项目(使用多模块POM),我会得到以下Maven错误:

Caused by: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from A 1.0.0.qualifier to package org.apache.axis2.transaction 0.0.0.", "Unable to satisfy dependency from A 1.0.0.qualifier to package org.apache.axis2.addressing.i18n 0.0.0.", ...

为什么以聚合方式构建项目会导致此错误,如果这是Tycho错误,可以采用哪种解决方法?

但是,如果我只在聚合POM中保留一个模块(独立于哪一个),则没有错误。

编辑

无法使用类似的小型多模块样本进行重现。这意味着我的POM层次结构有一些东西。

EDIT2

能够在包含相同的依赖关系(一对轴2和公理库)之后,使用类似的小模块样本重现

EDIT3:简约示例

现在我想知道问题是否遗漏了我所包含的第三方库所需的所有第三方。如果是这样,那么为什么我能够在单独执行两个模块时成功构建,并且仅在通过父模块,多模块pom.xml完成​​时才构建失败?下面的示例仅包含一个单轴2内核JAR,捆绑在名为 first-thirdparty 的pom-first工件中。

而不是A,示例有keywoard first。文件夹结构如下:

./pom.xml
./first-thirdparty
    pom.xml
./first
    src/main/java/org/mydemo/Test.java // has just one method that simply returns AxisFault.class.getSimpleName(); to test import resolution
    META-INF/MANIFEST.MF
    build.properties
    pom.xml

Root pom:

<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>org.mydemo</groupId>
    <artifactId>first-aggregator</artifactId>

    <packaging>pom</packaging>
    <version>1.0.0-SNAPSHOT</version>


    <modules>
        <module>first-thirdparty</module>
        <module>first</module>
    </modules>

</project>

first-thirdparty的POM。它只是嵌入了axis2-kernel JAR(没有其他库..):

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <parent>
        <groupId>org.mydemo</groupId>
        <artifactId>first-aggregator</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <properties>
        <manifest-location>META-INF</manifest-location>
    </properties>

    <packaging>bundle</packaging>

    <groupId>org.mydemo</groupId>
    <artifactId>first-thirdparty</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>1.5.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Embed-Dependency>
                            axis2-kernel
                        </Embed-Dependency>
                        <_exportcontents>
                            org.apache.axis2.*;version="1.5.1"
                        </_exportcontents>
                        <Bundle-ClassPath>{maven-dependencies}</Bundle-ClassPath>
                        <Embed-Transitive>true</Embed-Transitive>
                        <Embed-Directory>jars</Embed-Directory>
                        <_failok>true</_failok>
                        <_nouses>true</_nouses>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

first的POM,这是一个eclipse-plugin,取决于first-thirdparty

<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>
    <parent>
        <groupId>org.mydemo</groupId>
        <artifactId>first-aggregator</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>org.mydemo</groupId>
    <artifactId>org.mydemo.first-bundle</artifactId>

    <packaging>eclipse-plugin</packaging>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <tycho.ver>0.14.1</tycho.ver>
    </properties>

    <repositories>
        <repository>
            <id>helios</id>
            <layout>p2</layout>
            <url>http://download.eclipse.org/releases/indigo</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.mydemo</groupId>
            <artifactId>first-thirdparty</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build> 
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho.ver}</version>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>target-platform-configuration</artifactId>
                <version>${tycho.ver}</version>
                <configuration>
                    <pomDependencies>consider</pomDependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

模块first的MANIFEST.MF;它显式导入了axis2-kernel的所有包:

Manifest-Version: 1.0
Bundle-Version: 1.0.0.qualifier
Tool: Bnd-0.0.357
Bundle-Name: first-bundle
Bnd-LastModified: 1334819004300
Created-By: 1.6.0_25 (Sun Microsystems Inc.)
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.mydemo.first-bundle
Export-Package: org.mydemo
Import-Package: org.apache.axis2.clustering.context,
 org.apache.axis2.modules,
 org.apache.axis2.deployment.util,
 org.apache.axis2.dataretrieval.client,
 org.apache.axis2.clustering,
 org.apache.axis2.wsdl.util,
 org.apache.axis2.clustering.configuration,
 org.apache.axis2.java.security,
 org.apache.axis2.deployment.resolver,
 org.apache.axis2.util,
 org.apache.axis2.wsdl,
 org.apache.axis2.addressing.metadata,
 org.apache.axis2.i18n,
 org.apache.axis2.deployment.scheduler,
 org.apache.axis2.dataretrieval,
 org.apache.axis2.dispatchers,
 org.apache.axis2.transport,org.apache.axis2.service,
 org.apache.axis2.deployment.repository.util,
 org.apache.axis2.client,
 org.apache.axis2.context,
 org.apache.axis2.classloader,
 org.apache.axis2.receivers,
 org.apache.axis2.engine,
 org.apache.axis2.addressing,
 org.apache.axis2.deployment,
 org.apache.axis2.transport.http,
 org.apache.axis2.phaseresolver,
 org.apache.axis2.context.externalize,
 org.apache.axis2.transaction,
 org.apache.axis2.description,
 org.apache.axis2.addressing.wsdl,
 org.apache.axis2.transport.http.util,
 org.apache.axis2.util.threadpool,
 org.apache.axis2,
 org.apache.axis2.handlers,
 org.apache.axis2.addressing.i18n,
 org.apache.axis2.builder,
 org.apache.axis2.description.java2wsdl,
 org.apache.axis2.builder.unknowncontent,
 org.apache.axis2.namespace,
 org.apache.axis2.description.java2wsdl.bytecode,
 org.apache.axis2.client.async,
 org.osgi.framework;version="1.3.0"
Bundle-Localization: plugin

2 个答案:

答案 0 :(得分:12)

不可能在同一个反应堆中构建“POM-first”捆绑包(即使用maven-bundle-plugin构建的捆绑包)和“MANIFEST-fist”捆绑包(即由Tycho建造的捆绑包)。这是known limitation in Tycho

原因是当maven-bundle-plugin尚未有机会生成Manifest(Tycho需要)时,Tycho在Maven生命周期中过早地进行依赖性解析。解决这个问题需要quite large changes,但我仍然希望在中期完成这项工作。

答案 1 :(得分:1)

我刚刚遇到同样的问题。我以这种方式解决我的问题希望这会对你有帮助

1您收到错误的原因是因为您缺少插件jar。例如在你的情况下 “引起:java.lang.RuntimeException:”找不到解决方案,因为问题不能令人满意。“:”“无法满足从1.0.0.qualifier到包org.apache.axis2.transaction 0.0.0的依赖关系。”, “ 只看第一个,你没有maven存储库中的“org.apache.axis2.transaction 0.0.0。”。老实说,我不确定什么是jar用于什么以及如何获得它,我只是从其他版本的eclipse中缺少一些插件依赖,所以我只需要/ in eclipse / plugins中的jar 所以你要做的就是自己创建一个p2存储库。这是另一个正确链接如何使用脚本来创建p2存储库http://maksim.sorokin.dk/it/2010/11/26/creating-a-p2-repository-from-features-and-plugins/

的人

2将此存储库放在ur maven pom文件中

    <repository>
        <id>localP2resp</id>
        <url>file:///F:/P2Repository</url>
        <layout>p2</layout>
    </repository>

3到目前为止,如果你有P2repository所需的插件罐,你应该解决这个问题

如果你有任何其他问题,或者不满意我的回答,请继续问thx