我有一个Eclipse RCP应用程序,它使用Tycho插件与Maven一起构建。有一个主POM,包含所有插件和功能作为模块。
如果我使用Maven安装主POM ,则生成的反应器构建工作正常。所有模块都已构建,安装成功。
但是,如果我单独构建一个Eclipse 插件,则依赖到应用程序的其他插件不能解决即可。
依赖第三方库(例如Eclipse平台)似乎正常工作。我们的应用程序的Eclipse插件只有这种类型的依赖项才能成功构建。
控制台输出如下:
[INFO] Resolving dependencies of MavenProject: com.mycompany.myproduct:com.mycompany.myproduct.gui.editors:1.8.15-SNAPSHOT @ /<path>/com.mycompany.myproduct.gui.editors/pom.xml
[INFO] Cannot complete the request. Generating details.
[INFO] Cannot complete the request. Generating details.
[INFO] {osgi.ws=gtk, osgi.os=linux, osgi.arch=x86, org.eclipse.update.install.features=true}
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: com.mycompany.myproduct.gui.editors 1.8.15.qualifier
[ERROR] Missing requirement: com.mycompany.myproduct.gui.editors 1.8.15.qualifier requires 'bundle com.mycompany.myproduct.preferences 1.8.15' but it could not be found
[ERROR]
[ERROR] Internal error: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from com.mycompany.myproduct.gui.editors 1.8.15.qualifier to bundle com.mycompany.myproduct.preferences 1.8.15.", "Unable to satisfy dependency from com.mycompany.myproduct.gui.editors 1.8.15.qualifier to bundle com.mycompany.myproduct.gui.utils 1.8.15.", "No solution found because the problem is unsatisfiable."] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from com.mycompany.myproduct.gui.editors 1.8.15.qualifier to bundle com.mycompany.myproduct.preferences 1.8.15.", "Unable to satisfy dependency from com.mycompany.myproduct.gui.editors 1.8.15.qualifier to bundle com.mycompany.myproduct.gui.utils 1.8.15.", "No solution found because the problem is unsatisfiable."]
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
...
由于反应堆构建成功,所有插件构建都在我们公司的存储库中(我们使用Artifactory)。在Artifactory Web应用程序中,我清楚地看到了preferences
插件的1.8.15-SNAPSHOT版本。但是,似乎无法访问此存储库。
存储库信息在settings.xml
文件中指定。请注意,已从该存储库成功检索父POM:
[INFO] Scanning for projects...
Downloading: http://artifactory.buildnet.mycompany.com/artifactory/libs-snapshot-local/com/mycompany/myproduct/gui.parent/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://artifactory.buildnet.mycompany.com/artifactory/libs-snapshot-local/com/mycompany/myproduct/gui.parent/1.0-SNAPSHOT/maven-metadata.xml (594 B at 3.3 KB/sec)
设置文件的内容是:
<settings>
<servers>
... (only relevant for deploy)
</servers>
<mirrors>
<mirror>
<id>mycompany-remote-mirror</id>
<name>mycompany remote repositories mirror</name>
<url>http://artifactory.buildnet.mycompany.com/artifactory/remote-repos</url>
<mirrorOf>*,!eclipse*,!mycompany-snapshots,!mycompany-releases</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>mycompany-default</id>
<repositories>
<repository>
<id>mycompany-snapshots</id>
<name>MyCompany snapshots repository</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://artifactory.buildnet.mycompany.com/artifactory/libs-snapshot-local</url>
<layout>default</layout>
</repository>
<repository>
<id>mycompany-releases</id>
<name>MyCompany releases repository</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://artifactory.buildnet.mycompany.com/artifactory/libs-release-local</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>mycompany-default</activeProfile>
</activeProfiles>
</settings>
这是父POM(请注意,在我们的项目中,它与包含模块的主POM分开):
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.myproduct</groupId>
<artifactId>gui.parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<product-id>MyProduct</product-id>
<tycho.version>0.17.0</tycho.version>
<tycho-extras.version>0.17.0</tycho-extras.version>
<eclipse.version>juno</eclipse.version>
<eclipse.repo>http://download.eclipse.org/releases/${eclipse-version}</eclipse.repo>
</properties>
<distributionManagement>
...
</distributionManagement>
<repositories>
<repository>
<id>eclipse</id>
<url>${eclipse.repo}</url>
<layout>p2</layout>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-versions-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- PARENT PLUGINS -->
<plugin>
<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>
...
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho.version}</version>
...
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-versions-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
</plugin>
<!-- END OF PARENT PLUGINS -->
<!-- DEFAULT PLUGINS -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<compilerArguments>
<inlineJSR/>
<enableJavadoc/>
<encoding>ISO-8859-1</encoding>
</compilerArguments>
</configuration>
</plugin>
<!-- END OF DEFAULT PLUGINS -->
<!-- OTHER PLUGINS -->
... (maven-resources, tycho-surefire, tycho-p2, tycho-p2-director,
tycho-p2-repository, ...)
<!-- END OF OTHER PLUGINS -->
</plugins>
</pluginManagement>
</build>
</project>
与其他插件有依赖关系的插件的POM.xml如下:
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.myproduct</groupId>
<artifactId>gui.parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>com.mycompany.myproduct.gui.editors</artifactId>
<version>1.8.15-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
同一个插件的MANIFEST.MF文件如下:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyProduct Editors Plug-in
Bundle-SymbolicName: com.mycompany.myproduct.gui.editors;singleton:=true
Bundle-Version: 1.8.15.qualifier
Bundle-Activator: com.mycompany.myproduct.gui.editors.Activator
Bundle-ActivationPolicy: lazy
Export-Package: com.mycompany.myproduct.gui.editors,
com.mycompany.myproduct.gui.editors.logger,
com.mycompany.myproduct.gui.editors.report
Bundle-Vendor: MyCompany
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.ui.workbench;bundle-version="3.104.0",
org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.jface;bundle-version="3.8.0",
com.mycompany.myproduct.preferences;bundle-version="1.8.15",
com.mycompany.myproduct.gui.utils;bundle-version="1.8.15",
org.eclipse.ui.workbench;bundle-version="3.104.0"
答案 0 :(得分:8)
Tycho没有查看Maven存储库来解析其依赖关系(因为Maven存储库没有足够的元数据来解析OSGi清单中指定的依赖关系)。相反,Tycho需要p2存储库来存储来自远程的工件。
因此,为了涵盖反应堆部件构建的用例,您需要执行以下操作:
通过这种方式,即使您没有同时构建其他模块,项目的工件也将成为模块target platform的一部分。
答案 1 :(得分:1)
我认为除了maven坐标之外,您还需要提供父级的相对路径。没有相对路径,只有当父pom已经至少在您的本地仓库中时,它才有效。