为什么tycho-surefire-plugin:test考虑Bundle-ClassPath而不是bin.includes?

时间:2016-07-16 23:10:23

标签: eclipse tycho surefire tycho-surefire-plugin

在我的eclipse插件项目中。我有一个特定的jar,我需要它在构建过程中可见,特别是在测试阶段,但是我不需要它在eclipse插件的运行时可见。我发现 tycho-surefire-plugin 正在使用 MANIFEST.MF 的Bundle-ClassPath中存在的jar而不是 build.properties <的bin.includes / strong>即可。有没有办法强制 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>

1 个答案:

答案 0 :(得分:1)

如果我理解你的问题:

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

为此,您必须使用target-platform-configuration插件进行测试,然后指定extraRequirements以包含仅测试依赖项。

target-platform-configuration示例:

  <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中。

希望这会有所帮助。