gpt4 book ai didi

eclipse - Tycho:单独构建插件时无法解决对项目其他插件的依赖

转载 作者:行者123 更新时间:2023-12-04 03:52:34 29 4
gpt4 key购买 nike

我有一个使用 Tycho 插件使用 Maven 构建的 Eclipse RCP 应用程序。有一个主 POM,其中包含作为模块的所有插件和功能。

如果我 安装主 POM 使用 Maven,生成的 react 器构建工作正常。所有模块均已构建,安装成功 .

然而 , 如果我构建 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)
...

由于 react 堆构建成功, 所有插件版本都在我们公司的存储库中 (我们使用 Artifactory)。在 Artifactory 网络应用程序中,我清楚地看到了 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"

最佳答案

Tycho 不会在 Maven 存储库中查找其依赖项(因为 Maven 存储库没有足够的元数据来解析 OSGi list 中指定的依赖项)。相反,Tycho 需要来自远程的 Artifact 的 p2 存储库。

因此,为了涵盖构建 react 器部件的用例,您需要执行以下操作:

  • 让 CI 构建生成一个 p2 存储库,该存储库聚合来自 react 器的所有 Artifact ,并在静态 URL 上发布该 p2 存储库。 (最简单的解决方案是使用 Jenkins 作业并使用指向构建工作区的 URL。)
  • 在您的项目中创建一个配置文件,将 CI 构建 p2 存储库添加为 POM 中具有布局 p2 的存储库。

  • 这样,项目的 Artifact 也将成为模块 target platform 的一部分。即使您不同时构建其他模块。

    关于eclipse - Tycho:单独构建插件时无法解决对项目其他插件的依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16236113/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com