使用 Tycho 构建片段时出错:"xyz.fragment cannot be installed in this environment because its filter is not applicable"

Error when building fragment with Tycho: "xyz.fragment cannot be installed in this environment because its filter is not applicable"

虽然 运行 mvn install 在 Eclipse 中的一个片段项目上我得到了这个错误:

${fragment name} cannot be installed in this environment because its filter is not applicable.

在清单中使用 Eclipse-PlatformFilter: (osgi.os=macosx) 会破坏构建。

这是围绕密钥错误的输出(IDs/directory 名称已编辑):

[INFO] Resolving dependencies of MavenProject: ${fragmentID}:4.3.0-SNAPSHOT @ ${fragmentDir}/pom.xml
[INFO] {osgi.os=linux, org.eclipse.update.install.features=true, osgi.arch=x86_64, osgi.ws=gtk}
[ERROR] Cannot resolve project dependencies:
[ERROR]   Problems resolving provisioning plan.:
[ERROR]      ${fragment name} cannot be installed in this environment because its filter is not applicable.
[ERROR] 
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.

link (http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting) 没有帮助。

我在网上发现了几个类似的错误(component X cannot be installed in this environment because its filter is not applicable),但都是适用于下载软件的情况,要么没有解决方案,要么解决方案不适用于我的情况。

感谢任何帮助!

编辑: 我发现在主机插件中使用 Eclipse-PlatformFilter: (osgi.os=macosx) 有效,在片段中使用 Eclipse-PlatformFilter: (| (osgi.os=macosx) (osgi.os=linux) (osgi.os=win32) ) 也有效。似乎构建通过了祖先 pom 中设置的每个环境,并且当片段不适用于这些环境中的任何一个时它就会中断......当然有一些我可以设置的标志来防止这种情况?

Tycho 为通过 POM 配置的所有操作系统环境构建。当前无法自动将这些环境过滤为配置为 Eclipse-PlatformFilter 的环境。所以只为某个操作系统构建片段时,需要在片段的POM中手动覆盖父POM中的<environments>配置:

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>${tycho-version}</version>
            <configuration>
                <environments>
                    <environment>
                        <os>macosx</os>
                        <ws>cocoa</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
            </configuration>
        </plugin>
    </plugins>
</build>