I’m currently working on creating a custom plugin with custom rules, I’ve managed that. I’m having some issues figuring out how to create a new Profile to be available in SonarQube while inheriting from the SonarWay Java Profile. I’m using the BuiltInQualityProfilesDefinition to create the profile definition and it works, but can’t seem to figure out how to also inherit from the JavaSonarWayProfile to be able to include all those rules.
I don’t think there is a way to have built-in profiles inheriting from each other. You will have to repeat all the rules you want in your custom profile.
No, BuiltInQualityProfile extension point is evaluated during server startup to initialize the quality profiles. That’s too early to get access to other quality profiles (would create a loop).
Not at runtime. The extension plugin I’m writing has dependencies on the Java plugin so the SonarWay profile class is available, it’s just not “built” I think.
You are depending on a specific version of SonarJava at compile time, but it doesn’t mean it will be the same version installed on the server. And consequently some rules may not exists.
Still if you want to automate extracting rules of SonarWay at build time, you should maybe look at the unit test:
I’m still trying to understand the best practices or what functionality I could/should provide and what should be left to the user. For example I saw that findbugs does depend on the java plugin as well, here:
So I thought that’d be an acceptable way to provide a quick way for the user to switch from the built in plugin to one that just adds a few new ones that we provide. Just trying to figure out the best way to do that.