简体   繁体   English

如何将Tycho加载平台特定片段放入任何操作系统的测试运行时?

[英]How can I make Tycho load platform specific fragment into the test runtime for any OS?

I'm using Tycho to build and test some eclipse plugins. 我正在使用Tycho来构建和测试一些eclipse插件。 I have one bundle that has many platform specific fragments. 我有一个包含许多平台特定片段的包。 I also have one test bundle that is using tycho-surefire-plugin to test the original bundle that has the platform specific fragments. 我还有一个测试包,它使用tycho-surefire-plugin来测试具有平台特定片段的原始包。 However, Tycho is not including the current platform's fragment into the test runtime. 但是,Tycho不会将当前平台的片段包含在测试运行时中。

All of the platform specific fragments look like the win64 fragment manifest listed below. 所有特定于平台的片段看起来都像下面列出的win64片段清单。 (There are actually six fragments in total, one for each platform combination I need to support.) (实际上总共有六个片段,每个平台组合需要支持一个片段。)

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Liferay AUI Upgrade Tool Win64
Bundle-SymbolicName: com.liferay.laut.win32.win32.x86_64;singleton:=true
Bundle-Version: 1.0.2.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Fragment-Host: com.liferay.ide.alloy.core
Eclipse-BundleShape: dir
Eclipse-PlatformFilter: (& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86_64))
Bundle-Vendor: Liferay, Inc.

Example win64 fragment pom.xml's <build> section 示例win64片段pom.xml的<build>部分

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <configuration>
                <environments>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
            </configuration>
        </plugin>
    </plugins>
</build>

When I try to execute my Tycho build and it runs the surefire test plugin (no matter which OS I try), the correct platform fragment is not added into the runtime. 当我尝试执行我的Tycho构建并运行surefire测试插件时(无论我尝试哪种操作系统),都没有将正确的平台片段添加到运行时。

I've seen various posts on stackoverflow about similar questions but in those cases the fragments loaded into the test runtime were not platform-specific fragments with OS filters. 我已经在stackoverflow上看到关于类似问题的各种 帖子 ,但在这些情况下,加载到测试运行时的片段不是具有OS过滤器的特定于平台的片段。

This is a good question - but if you know the right trick, the solution is fortunately not complicated: Simply configure Tycho to include the feature which contains all fragments into the test runtime. 这是一个很好的问题 - 但如果您知道正确的技巧,那么解决方案幸运的并不复杂:只需将Tycho配置为将包含所有片段的功能包含在测试运行时中。

  1. Create a feature in an eclipse-feature module which includes all the native fragments. eclipse-feature模块中创建一个包含所有本机片段的功能。 Make sure that the platform filters for each plug-in is correct: On the Plug-Ins tab of the feature.xml editor, you need to select the correct os/ws/arch that each fragment applies to. 确保每个插件的平台过滤器都是正确的:在feature.xml编辑器的Plug-Ins选项卡上,您需要选择每个片段适用的正确os / ws / arch。 This is some manual effort, but typically can re-use this feature to include your fragments into a p2 repository/update site. 这是一些手动操作,但通常可以重复使用此功能将您的片段包含到p2存储库/更新站点中。

  2. Include this feature into the test runtime with the following POM configuration: 使用以下POM配置将此功能包含在测试运行时中:

     <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <dependency-resolution> <extraRequirements> <requirement> <type>eclipse-feature</type> <id>fragment-containing-feature</id> <versionRange>0.0.0</versionRange> </requirement> </extraRequirements> </dependency-resolution> </configuration> </plugin> 

A potential pitfall is the <environments> configuration of the eclipse-feature module: You don't need anything special for that module; 潜在的缺陷是eclipse-feature模块的<environments>配置:您不需要该模块的任何特殊内容; just have the module inherit the <environments> configuration from the parent POM. 让模块从父POM继承<environments>配置。 Note that the parent POM shall configure all the environments your build supports - and only the fragment modules need to override the global configuration. 请注意,父POM应配置构建支持的所有环境 - 并且只有片段模块需要覆盖全局配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何调试 Tycho 运行的测试用例? - How can I debug test cases run by Tycho? 如何使jenkins测试CDI运行时失败? - How can i make jenkins test for CDI runtime failures? 如何为我的跨平台Jar调用特定于OS X的方法? - How can I call an OS X-specific method for my cross-platform Jar? 如何在Mac OS X中检测Java运行时? - How can I detect the java runtime in Mac OS X? 如何使用onClick方法加载到特定的Fragment / Viewpager? - How do I load into a specific Fragment / Viewpager with an onClick method? 导入无法通过使用Tycho的测试插件片段解决,但可以在Eclipse中使用 - Import cannot be resolved by test plugin fragment using Tycho but works in Eclipse 如何在 CUBA 平台中使用按钮打开选项卡表的特定选项卡? - How can I open a specific Tab of a Tabsheet with an Button in CUBA Platform? 如何在 AWS Elastic Beanstalk 中使用 select 特定平台? - How I can select specific platform in AWS Elastic Beanstalk? 在失败的测试之后但在任何@After方法之前,如何使JUnit 4.8运行代码? - How can I make JUnit 4.8 run code after a failed test, but before any @After methods? 如何确保我的JUnit测试方法的特定清理始终运行? - How can I make sure my JUnit test method's specific cleanup always runs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM