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

Art*_*cis 8 tycho maven

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

  • A-thirdparty:带有打包'bundle'的项目,由maven-bundle-plugin构建,具有'Embed-Dependency'指令,并导出插件'A'所需的所有包
  • A:项目包装'eclipse-plugin',使用tycho-maven-plugin,以及Tycho的target-platform-configuration插件,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.", ...
Run Code Online (Sandbox Code Playgroud)

为什么以聚合方式构建项目会导致此错误,如果这是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
Run Code Online (Sandbox Code Playgroud)

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

POM的first-thirdparty.它只是嵌入了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>
Run Code Online (Sandbox Code Playgroud)

POM first,这是一个eclipse插件,依赖于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>
Run Code Online (Sandbox Code Playgroud)

MANIFEST.MF模块first; 它显式导入了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
Run Code Online (Sandbox Code Playgroud)

obe*_*ies 12

不可能在同一个反应堆中构建"POM-first"捆绑包(即使用maven-bundle-plugin构建的捆绑包)和"MANIFEST-fist"捆绑包(即由Tycho构建的捆绑包).这是第谷的一个已知限制.

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