Today I downloaded the SonarQube 7.6 and got an exception:
org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: com.analyzer.rules.IssuesLoaderSensor has unsatisfied dependency 'class org.sonar.api.profiles.RulesProfile' for constructor 'public com.analyzer.rules.IssuesLoaderSensor(org.sonar.api.config.Configuration,org.sonar.api.batch.fs.FileSystem,org.sonar.api.profiles.RulesProfile)' from ...
My constructor:
public IssuesLoaderSensor(final Configuration config, final FileSystem fileSystem, final RulesProfile rulesProfile) {
this.config = config;
this.fileSystem = fileSystem;
this.profile = rulesProfile;
}
I don’t use deprecated api, what could be the problem?
Hm, the file C:\Users\admin\.gradle\caches\modules-2\files-2.1\org.sonarsource.sonarqube\sonar-plugin-api\7.6\96797d65790726ebc4de618c52260226545b8ba0\sonar-plugin-api-7.6-sources.jar!\org\sonar\api\profiles\RulesProfile.java contains the old version of RulesProfile class.
I’m not sure about what is your question… The class exists in the .jar, but your IssuesLoaderSensor class is instantiated by SonarQube Scanner and it’s responsible for creating instances of Configuration, FileSystem and RulesProfile classes (to call the class constructor).
In the message above I’ve cited the path to the class file, which is in the Gradle cache. The class there doesn’t contain tags @deprecated, though API is of the 7.6. version. I don’t understand, why it is so.
Short answer: RulesProfile was indeed removed from scanner side IoC container. Use ActiveRules instead. We were not able to mark it as deprecated, since it is still usable by server side extensions.
Long answer: This class is part of the oldest bits of SonarQube, and was shared between server and scanner extension points. We tried to deprecate it in 5.2 to notify plugin developers they should stop using it from scanner side extension points. But server side extension point developers were complaining that the deprecation was causing false positive issues on their code, so we decided to revert the deprecation.
You can easily replace it by ActiveRules, that is a specific scanner side component, and there since a long time so your plugin will be backward compatible with older SQ versions. I apologize for what is kind of zero-day API break, but due to the limited expressiveness of @Deprecated annotation, we had no better idea.