【问题标题】:eclipse RCP maven/tycho missing requirement 'bundle org.eclipse.e4.core.di'eclipse RCP maven/tycho 缺少要求'bundle org.eclipse.e4.core.di'
【发布时间】:2018-02-16 13:53:33
【问题描述】:

有一个 Eclipse RCP/IDE-Plug-in 项目,它依赖于几个 Eclipse 模块,例如 org.eclipse.e4.core.diorg.eclipse.core.runtime

此项目在 Eclipse IDE for Committers 环境中编译,并带有一个用于依赖设置的 .target 文件。

我想为此项目添加一个无头 maven/tycho 构建,导致错误如下:

[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: org.myplugin.someservice 1.0.0
[ERROR]   Missing requirement: org.myplugin.someservice 1.0.0 requires 'bundle org.eclipse.e4.core.di 0.0.0' but it could not be found

项目设置如下所示:

releng/
     org.myplugin.releng/
          pom.xml (contains tycho-plugins def, modules, target ref)
     org.myplugin.target/
          Neon.target
          pom.xml (contains 'eclipse-target-definition')
plugins/
    org.myplugin.someservice/
          pom.xml
          META-INF/
              MANIFEST.MF (contains reference to org.eclipse.e4.core.di)

我使用了来自 Lars Vogel (http://www.vogella.com/tutorials/EclipseTycho/article.html#exercise-using-a-target-platform-for-the-build) 的教程进行基本设置和理解。

目标文件的内容是:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?><target name="Neon" sequenceNumber="43">
    <locations>
        <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="false" type="InstallableUnit">
            <unit id="org.eclipse.platform.sdk" version="4.6.3.M20170301-0400"/>
            <unit id="org.eclipse.pde.feature.group" version="3.12.3.v20170301-0400"/>
            <unit id="org.eclipse.pde.source.feature.group" version="3.12.3.v20170301-0400"/>
            <unit id="org.eclipse.platform.ide" version="4.6.3.M20170301-0400"/>
            <unit id="org.eclipse.equinox.sdk.feature.group" version="3.12.0.v20170209-1843"/>
            <unit id="org.eclipse.rcp.feature.group" version="4.6.3.v20170301-0400"/>
            <repository location="http://download.eclipse.org/eclipse/updates/4.6"/>
        </location>
        <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="false" type="InstallableUnit">
            <unit id="org.eclipse.emf.cdo.epp.feature.group" version="4.5.0.v20160607-1511"/>
            <unit id="org.eclipse.emf.sdk.feature.group" version="2.12.0.v20160526-0356"/>
            <unit id="org.eclipse.emf.compare.diagram.papyrus.feature.group" version="3.2.1.201608311750"/>
            <unit id="org.eclipse.xtext.sdk.feature.group" version="2.10.0.v201605250459"/>
            <unit id="org.eclipse.gmf.runtime.sdk.feature.group" version="1.10.0.201606071959"/>
            <unit id="org.eclipse.gmf.runtime.notation.sdk.feature.group" version="1.10.0.201606071631"/>
            <unit id="org.eclipse.uml2.sdk.feature.group" version="5.2.3.v20170227-0935"/>
            <unit id="org.eclipse.emf.compare.ide.ui.feature.group" version="3.2.1.201608311750"/>
            <repository location="http://download.eclipse.org/releases/neon"/>
        </location>
    </locations>
</target>

这主要捕获了我的 Eclipse 安装信息打印出的有关已安装软件的内容。

target/pom.xml 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.myplugin</groupId>
        <artifactId>org.myplugin.releng</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../org.myplugin.releng/pom.xml</relativePath>
    </parent>
    <groupId>org.myplugin</groupId>
    <artifactId>org.myplugin.target</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>eclipse-target-definition</packaging>
</project>

releng/pom.xml 相当大,它指定了所有 maven/tycho 插件、用于依赖解析的目标文件、目标平台以及作为模块的所有插件和功能。

对于一个失败的插件,pom.xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.myplugin</groupId>
    <artifactId>org.myplugin.releng</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <relativePath>../../org.myplugin.releng/pom.xml</relativePath>
  </parent>
  <groupId>org.myplugin</groupId>
  <artifactId>org.myplugin.someservice</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>eclipse-plugin</packaging>
</project>

我在 stackoverflow 上阅读了许多类似的问题,并尝试了许多修复:

  • 移除版本标签target/pom.xml,
  • 删除相对路径,
  • 使用 pom 代替 eclipse-target-definition
  • 还有更多

没有任何效果。那么我在这里错过了什么?

编辑: 据我了解,releng/pom.xml 应该设置 tycho 插件和 maven 的东西。然后执行mvn clean verfiy 命令应该构建解决方案,而releng/pom.xml 中指定的Neon.target 定义采用target/pom.xmltarget/Neon.target 来获取Eclipse 环境(包括org.eclipse.e4.core.diorg.eclipse.core 东西)以及任何进一步定义依赖关系。

EDIT2: 我的eclipse-target-definition 插件是这样配置的:

<profile>
    <id>Neon.target</id>
    <activation>
        <activeByDefault>false</activeByDefault>
    </activation>
    <properties>
        <xtext-version>2.10.0</xtext-version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>target-platform-configuration</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <includePackedArtifacts>true</includePackedArtifacts>
                    <target>
                        <artifact>
                            <groupId>org.myplugin</groupId>
                            <artifactId>org.myplugin.target</artifactId>
                            <version>1.0.0-SNAPSHOT</version>
                            <classifier>org.myplugin.target</classifier>
                        </artifact>
                    </target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

EDIT3:我使用的是第谷版本 1.0.0

EDIT4 修正了target/pom.xml 中的一个错字。

【问题讨论】:

  • 你能在 Eclipse Target Editor 中打开你的Neon.target。等到 Eclipse 解析了目标平台,然后在 Contents 选项卡上仔细检查 org.eclipse.e4.core.di 是否确实包含在您的目标平台中。
  • 好的,你的Neon.target确实确实包含org.eclipse.e4.core.di(我自己仔细检查了一遍)。但是您的org.myplugin.someservice 插件是否在其pom.xml(或其父级之一)中配置了target-platform-configuration Maven 插件?
  • 我将目标平台配置插件的配置附加为 EDIT2。此配置位于 org.myplugin.releng 的父 pom.xml 中。
  • 三个备注:首先org.myplugin.target&lt;classifier&gt;看起来不对; org.myplugin.target POM 中的 AFAICT,.target 文件在没有分类器的情况下部署(在 ~/.m2/repository/ 中仔细检查)。 第二,你的.target文件真的叫org.myplugin.target.target吗? Tycho expects it to be named {project.artifactId}.target第三Neon.target 配置文件在构建时是否处于活动状态? (使用mvn help:active-profilesmvn help:effective-pom 进行检查。)
  • 好的,所以:首先:我不知道分类器还必须在org.myplugin.target POM 中指定。我在哪里可以读到这个? (从org.myplugin.releng POM 中删除它仍然失败)第二{project.artifactId}org.myplugin.target,其目标文件称为org.myplugin.target.target(是的,它很难看)第三:这些命令失败,并出现相同的Missing Requierement ... 错误。

标签: java eclipse maven rcp tycho


【解决方案1】:

您需要使用-P Neon.target 运行Maven 来激活您的&lt;profile&gt;;否则您的 target-platform-configuration 将不会成为构建的一部分。

就个人而言,我会总是在任何 &lt;profile&gt; 之外有一个默认的 target-platform-configuration。例如,这可能是当前 Eclipse 版本的目标定义(在撰写本文时:Oxygen)。我只会将 ` 用于 unusual 目标定义,例如较旧的 Eclipse 版本(在您的情况下:Neon)。但这只是我个人的最佳实践。

【讨论】:

    【解决方案2】:

    实际上我解决了我的问题,但不像我预期的那样。我认为它不应该工作,但现在它是这样工作的:

    根据this question的回答,我在org.myplugin.releng/pom.xml父pom中添加了以下配置:

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

    我以前这样做过,但错过了我在 pom.xml 的其他地方已经有一个 repositories 部分,这导致它失败并且在我的愤怒中迷失了那个轨道:D

    实际上我仍然认为它应该从目标文件中获取该信息。我注意到在成功构建时,目标文件是在父 pom 之后评估的,导致它在处理目标定义文件之前需要所有依赖项。

    我敢打赌,我的配置仍然有问题,但至少现在可以构建。如果有人有任何想法,虽然它会以某种方式让我感到宽慰:)

    【讨论】:

    • 你是对的:&lt;repository&gt; 不应该是必需的; eclipse-target-definition 应该做所有的工作。 “[T] 在父 pom 之后评估目标文件”是意料之中的,但在 building any 项目 Tycho 尝试 resolve 之前每个项目的目标平台。为此,所有(尚未构建的)eclipse-target-definition 项目必须严格遵守the naming convention for the .target file,以便 Tycho 可以在您的项目目录中找到目标文件。
    猜你喜欢
    • 2018-05-16
    • 2012-07-20
    • 1970-01-01
    • 2017-12-30
    • 2020-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多