Reputation: 3928
I have a test failure due to an IllegalStateException
from Platform.getPlugin("...")
which calls @Deprecated
org.eclipse.core.runtime.Platform.getPluginRegistry()
which "only works if the compatibility layer is installed and must not be used otherwise."
This test works in-workspace during development, but fails (reproducible) when ran by Maven Tycho Surefire. I gathered that this has something to do with org.eclipse.core.runtime.compatibility
, so have attempted to do this in the 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>
Unfortunately even with this (above) it still does not work - what am I doing wrong?
As an alternative Answer to fix this, I guess I could try to adapt that line in the test to use another API than this deprecated Platform.getPlugin()
- but how do you obtain an org.eclipse.core.runtime.Plugin given an ID without using any deprecated APIs requiring this compatibility layer which is causing me issues here?
Upvotes: 0
Views: 114
Reputation: 3928
Actually simply Platform.getBundle()
instead of Platform.getPlugin()
did the trick.
Also, just in case anyone else ever hits this, the extra dependency configuration does work - it just lead to ANOTHER unrelated IllegalStateException in my specific test case, which caused me confusion.
Upvotes: 1