Hello SonarQube Community,
I have developed a custom SonarQube plugin with custom rules for Java, and I am facing an issue where SonarQube plugin in IntelliJ does not recognize these custom rules. Here’s the situation:
Environment Details:
• SonarQube Server Version: Community Edition v25.1.0.102122 (running in a Docker container)
Custom SonarQube Plugin Project:
•. SonarQube Plugin API: org.sonarsource.api.plugin:sonar-plugin-api:11.1.0.2693
• Gradle Project with Quarkus and Java 17
Plugin metadata:
manifest {
attributes(
'Plugin-Name': 'Custom SonarQube Plugin',
'Plugin-Key': 'plugin-key',
'Plugin-Version': version,
'Plugin-Class': 'de.example.sonarqube.CustomSonarPlugin',
'JRE-Min-Version': '17',
'Plugin-RequiredForLanguages': 'java',
'Bundle-Name': 'Custom SonarQube Plugin',
'Bundle-SymbolicName': 'de.example.sonarqube',
'Bundle-Version': version,
'Bundle-ManifestVersion': '2',
'SonarLint-Supported': 'true',
'SonarLint-Rules-Definition': 'de.example.sonarqube.CustomRulesDefinition',
'SonarLint-Repository-Key': 'my-repo-key',
'SonarLint-Languages': 'java',
'SonarLint-Required-Languages': 'java'
)
}
Analysed Project:
• SonarQube Gradle Plugin: org.sonarqube 6.0.1.5171
• SonarQube for IDE Plugin 10.17.0.80539 (IntelliJ Ultimate) in Connected Mode
• Gradle Project with Quarkus and Java 21
The Issue:
• Running ./gradlew sonar --info correctly detects custom rule violations and reports them on the SonarQube web interface (http://localhost:9000).
• However, running the analysis from IntelliJ using the SonarQube for IDE plugin does not highlight custom issues neither in the IDE nor in the SonarQube UI.
• Standard SonarQube rules work fine — only the custom rules are missing from IDE plugin’s results.
Troubleshooting Done:
- Verified that the custom rules are properly registered:
• The rules appear in Rules in the SonarQube UI and are active.
• Running curl -X GET “http://localhost:9000/api/rules/search?repositories=my-repo-key” returns my custom rules. - Ensured the correct SonarQube configuration in the analyzed project (build.gradle):
sonarqube { properties { property "sonar.projectKey", "my_project" property "sonar.host.url", "http://localhost:9000" property "sonar.token", "my_sonar_token" property "sonar.sourceEncoding", "UTF-8" property "sonar.show.rule.warnings", "true" property "sonar.show.issues.on.editor", "true" property "sonar.sonarlint.projectServerSideAnalysis", "true" property "sonar.plugins.dir", "/opt/sonarqube/extensions/plugins" } }
Question: Do I need any additional properties to make SonarLint recognize custom rules?
- Checked SonarLint Cache & Rebind in IntelliJ:
• Cleared ~/.sonarlint and ~/Library/Caches/JetBrains/IntelliJIdea2024.1/sonarlint.
• Re-added the SonarQube Server Binding in IntelliJ.
• Still, custom issues do not appear. - Checked SonarQube Logs for Errors:
• No errors related to rule loading.
• The plugin is correctly loaded at startup.
The Question:
Do I need special configuration or properties in:
- The custom SonarQube plugin project (where I create the custom rules)?
- The analyzed project (where I run SonarQube analysis)?
If Gradle-based analysis (./gradlew sonar --info) detects custom issues but SonarQube for IDE does not, what could be missing?
Any guidance would be greatly appreciated!
Thanks in advance.
Marc