我必须使用 Maven/Tycho 构建一个 Eclipse 插件,该插件依赖于其他第 3 方。由于 Tycho 尚不支持嵌入依赖项,因此我将项目分为以下两个:
A-thirdparty
:带有打包“bundle”的项目,由maven-bundle-plugin构建,具有“嵌入依赖”指令,并导出插件“A”所需的所有包A
: 使用 tycho-maven-plugin 和 Tycho 的 target-platform-configuration 插件打包为 'eclipse-plugin' 的项目,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.", ...
为什么以聚合方式构建项目会导致此错误,如果这是第谷错误,可能会有什么样的解决方法?
但是,如果我在聚合 POM 中只留下一个模块(独立于哪个模块),则没有错误。
编辑
无法使用类似的小型多模块样本进行复制。这意味着我的 POM 层次结构有些问题。
编辑2
在包含相同的依赖项集(几个axis2和axiom库)之后,能够使用一个小的、类似的多模块样本进行重现。
EDIT3:简约示例
现在我想知道问题是否与我包含的第三方库所需的所有第三方有关。如果是这样,那么为什么我能够在分别执行两个模块时成功构建,而只有在通过父多模块 pom.xml 完成时构建才会失败?下面的示例仅包含一个单一的 axis2-kernel JAR,捆绑在名为first-thirdparty的 pom-first 工件中。
而不是A
, example 有 keyword 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
根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>
的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>
的 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>
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