来自pxy.xml的依赖关系,未被Eclipse在Tycho项目中考虑 [英] Dependencies from pom.xml not considered by Eclipse in Tycho Project

查看:127
本文介绍了来自pxy.xml的依赖关系,未被Eclipse在Tycho项目中考虑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有 eclipse-plugin 包装的Tycho项目。该项目包括通过pom.xml指定的一些依赖项。相关的pom部分是:

I created a Tycho project with an eclipse-plugin packaging. The project includes some dependencies that are specified via pom.xml. The relevant pom sections are:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <tycho.version>0.15.0</tycho.version>
</properties>
<build>
    <sourceDirectory>src</sourceDirectory>
    <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>
                <pomDependencies>consider</pomDependencies>
                <environments>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86_64</arch>
                    </environment>
                    <environment>
                        <os>macosx</os>
                        <ws>cocoa</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
            </configuration>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>juno</id>
        <layout>p2</layout>
        <url>http://download.eclipse.org/releases/juno</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.release</id>
        <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/release</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>com.springsource.org.testng</artifactId>
        <version>6.4.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.guice</groupId>
        <artifactId>com.springsource.com.google.inject</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.aopalliance</groupId>
        <artifactId>com.springsource.org.aopalliance</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

清单是:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Plugin-project-pure
Bundle-SymbolicName: plugin-project-pure
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.equinox.app,
 org.eclipse.uml2.uml;bundle-version="4.0.0",
 org.eclipse.uml2.uml.resources;bundle-version="4.0.0",
 org.junit;bundle-version="4.10.0",
 com.springsource.org.testng;bundle-version="[6.4.0,6.4.0]"

该项目只包含使用 org.testng.annotations 中的注释的默认包中的类,以便在编译期间测试依赖关系包括。

The project only consists of a class in the default package that uses an annotation from org.testng.annotations to test that during compilation the dependency is included.

如果我在Maven 3.0.4的命令行上构建项目,一切正常。在Eclipse Juno中导入项目后,我会收到多个错误。最重要的一个是在清单中,它指出bundle com.springsource.org.testng 无法解决。在类中也有一个编译错误,因为不能导入注释。该项目配置了Maven自然。我是否缺少某些东西,以便Eclipse Juno也可以考虑pom的依赖性?

If I'm building the project on the command line with Maven 3.0.4 everything works fine. After importing the project in Eclipse Juno, I get multiple errors. The most important one is in the manifest and it states that the bundle com.springsource.org.testng can't be resolved. There is also a compile error in the class, because the import of the annotation is not possible. The project has the Maven Nature configured. Am I missing something so that Eclipse Juno will also consider the dependencies of the pom?

推荐答案

您可以规避分割项目的这个问题分为两部分:

You can circumvent this problem splitting your project build into two parts:


  • 首先,将您的POM依赖项聚合到p2资源库中。您将需要一个 eclipse功能和一个 eclipse-repository 模块,加上单独的父POM,列出POM依赖关系并配置 pomDependencies =考虑

  • 在第二个构建中,将第一个构建中的p2存储库添加到目标平台,例如通过 jar:file:指向您当地Maven存储库中的构建结果的URL。

  • First, aggregate your POM dependencies into a p2 repository. You'll need an eclipse-feature and an eclipse-repository module for this, plus a separate parent POM that lists the POM dependencies and configures pomDependencies=consider.
  • In the second build, add the p2 repository from the first build to the target platform, e.g. via a jar:file: URL pointing to the build result in your local Maven repository.

然后,您还可以在Eclipse中配置目标平台以包含第一个构建中的p2存储库(这取决于您当前如何配置它)。如果您使用所谓的目标定义文件,您可以在Tycho和Eclipse之间获得最佳的一致性,您可以在Eclipse和Tycho中同时使用它们作为目标平台。

Then, you can also configure your target platform in Eclipse to include the p2 repository from the first build (which depends on how you currently configure it). You'll get the best consistency between Tycho and Eclipse if you use a so-called target definition file, which you can use both as target platform in Eclipse and in Tycho.

我知道所有这一切都是相当多的努力设置,但是AFAIK没有更好的解决方案可以充分发挥作用。

I am aware that all this is quite a bit of effort to set up, but AFAIK there are no better solutions that fully work.

这篇关于来自pxy.xml的依赖关系,未被Eclipse在Tycho项目中考虑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆