【问题标题】:How to enable/install the "compatibility layer" in Maven Tycho Surefire so that Platform.getPlugin() works如何在 Maven Tycho Surefire 中启用/安装“兼容层”以便 Platform.getPlugin() 工作
【发布时间】:2016-01-27 17:44:50
【问题描述】:

我 have a test failure 由于来自 Platform.getPlugin("...") 的 IllegalStateException 调用 @Deprecated org.eclipse.core.runtime.Platform.getPluginRegistry() “仅在安装兼容层时才有效,否则不得使用。”

此测试在开发期间可在工作空间中运行,但在由 Maven Tycho Surefire 运行时会失败(可重现)。我收集到这与org.eclipse.core.runtime.compatibility 有关,因此尝试在pom.xml 中执行此操作:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-surefire-plugin</artifactId>
    <version>${tycho-version}</version>
    <configuration>
        ...     
        <dependencies>
            <dependency>
                <type>p2-installable-unit</type>
                <artifactId>org.eclipse.core.runtime.compatibility</artifactId>
            </dependency>
        </dependencies>
        <bundleStartLevel>
            <bundle>
                <id>org.eclipse.core.runtime.compatibility</id>
                <level>4</level>
                <autoStart>true</autoStart>
            </bundle>
        </bundleStartLevel>
    </configuration>

不幸的是,即使有了这个(上面)它仍然无法正常工作 - 我做错了什么?

作为解决此问题的替代答案,我想我可以尝试在测试中调整该行以使用除已弃用的 Platform.getPlugin() 之外的其他 API - 但是您如何获得给定的 org.eclipse.core.runtime.Plugin没有使用任何需要此兼容层的已弃用 API 的 ID,这会导致我出现问题?

【问题讨论】:

    标签: eclipse-plugin tycho e4 tycho-surefire-plugin


    【解决方案1】:

    实际上只需Platform.getBundle() 而不是Platform.getPlugin() 就可以了。

    此外,以防万一其他人遇到此问题,额外的依赖配置确实有效 - 它只会在我的特定测试用例中导致另一个不相关的 IllegalStateException,这让我感到困惑。

    【讨论】:

    • 很高兴您解决了这个问题,但请注意 getPlugin() 和 getBundle() 之间的区别。第一个返回插件(即捆绑激活器),而后者返回捆绑描述符。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 2015-12-09
    • 1970-01-01
    • 2022-01-16
    • 2015-08-09
    • 2013-09-04
    • 2014-04-27
    相关资源
    最近更新 更多