Hi,
Using the class directly from the sonar-java plugin is not possible due to the isolated classloaders utilized by the plugins, as explained in the SonarQube docs.
Plugins are loaded in isolated classloaders. It means a plugin can’t access another plugin’s classes. There is an exception for package names following pattern
org.sonar.plugins.<pluginKey>.api
. For example, all classes in a plugin with the keymyplugin
that are located inorg.sonar.plugins.myplugin.api
are visible to other plugins.
In general, a plugin cannot access classes from another plugin, except for those that follow that specific package naming convention. Therefore, only the SonarQube API and classes from org.sonar.plugins.java.api.*
are available to your plugin.
This example seems to be relevant to what you’re implementing: https://github.com/SonarSource/sonar-java/blob/master/its/plugin/plugins/java-extension-plugin/src/main/java/org/sonar/samples/java/JavaExtensionRulesDefinition.java