我有一个测试失败,因为IllegalStateException
from Platform.getPlugin("...")
which 调用@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>
不幸的是,即使有这个(上面)它仍然不起作用 - 我做错了什么?
作为解决此问题的替代答案,我想我可以尝试在测试中调整该行以使用不推荐使用的其他 API Platform.getPlugin()
- 但是如何在不使用任何不推荐使用的情况下获得给定 ID 的 org.eclipse.core.runtime.Plugin需要此兼容层的 API 会导致我出现问题吗?