2

在我的 Eclipse 插件项目中。我有一个特定的 jar,我需要它在构建过程中特别是在测试阶段可见,但是我不需要它在 eclipse 插件的运行时可见。我发现tycho-surefire-plugin正在使用MANIFEST.MF的 Bundle-ClassPath 中存在的 jar,而不是build.properties的 bin.includes 。有什么方法可以强制tycho-surefire-plugin从 build.properties 而不是 MANIFEST.MF 获取其类路径?正如我所见,这是两个文件之间的正常差异。

我的片段测试项目 pom 如下:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.myproject</groupId>
        <artifactId>projectparent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../../../../projectparent/pom.xml</relativePath>
    </parent>

    <artifactId>com.myproject.projecttest</artifactId>
    <packaging>eclipse-test-plugin</packaging>
    <name>${project.artifactId}</name>
    <description>
        Tests for my project
    </description>

    <properties>
        <maven.site.skip>true</maven.site.skip>
        <maven.site.deploy.skip>true</maven.site.deploy.skip>
    </properties>
</project>
4

1 回答 1

1

如果我正确理解了您的问题:

  • 您有一些依赖项,您只需要在测试阶段使用它们,而不是将它们包含在您的产品中。

为此,您必须使用目标平台配置插件进行测试,然后指定 extraRequirements仅包含您的测试依赖项。

示例目标平台配置:

  <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>${tycho.version}</version>
            <configuration>
                <environments>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
                <dependency-resolution>
                    <optionalDependencies>ignore</optionalDependencies>
                    <extraRequirements>
                        <requirement>
                            <type>eclipse-plugin</type>
                            <id>org.eclipse.ui</id>
                            <versionRange>0.0.0</versionRange>
                        </requirement>
                        <requirement>
                            <type>eclipse-plugin</type>
                             <id>org.eclipse.ui.views</id>
                            <versionRange>0.0.0</versionRange>
                        </requirement>
                        <requirement>
                            .....
                        </requirement>
                    </extraRequirements>
                </dependency-resolution>
            </configuration>
        </plugin>

将其包含在您的测试 pom 中。

希望这可以帮助。

于 2016-07-22T09:47:19.933 回答