This plugin enhances the Java Plugin by providing the ability to import the Android Lint reports. The idea is to visualize Android Lint errors directly in SonarQube.
This plugin started out as a copy of https://github.com/ofields/sonar-android with source code converted from Java to Kotlin, and project structure converted from Maven to Gradle.
- Most Android projects are compiled with Gradle, so if this is the case use the SonarQube Scanner for Gradle to analyse your Android project
- Tune the SonarQube quality profile by activating the Android Lint rules on which you'd like to see some issues reported into SonarQube
- Configure the Gradle project to execute the Android Lint engine before launching the SonarQube analysis
- Define in the Gradle project the property sonar.android.lint.report (default value points to : build/outputs/lint-results.xml) to specify the path to the Android Lint report
- Run your Analyzer command from the project root dir
- Clone the repository
- run
gradlew clean build
in your terminal - copy the jar (in the new generated
build/libs
folder) to the<path_to_your_sonar_install>/extensions/plugins
folder in your SonarQube installation - restart sonar
- Change
versions.lint
inbuild.gradle
- Ensure
lint-rules-gen
compiles,gradlew :lint-rules-gen:build
- Run
lint-rules-gen
-gradlew clean build
TODO can we also execute the built artifact from Gradle? - Copy the generated XML to the correct location (from the root directory)
cp lint-rules-gen/out/org/sonar/plugins/android/lint/android_lint_sonar_way.xml sonar-android-plugin/src/main/resources/org/sonar/plugins/android/lint/android_lint_sonar_way.xml
cp lint-rules-gen/out/org/sonar/plugins/android/lint/rules.xml sonar-android-plugin/src/main/resources/org/sonar/plugins/android/lint/rules.xml
- go to
its/plugin/projects/SonarAndroidSample
and rungradlew lint
- Run the tests from the base directory
gradlew clean build
, fix as necessary. - Add missing rules to:
sonar-android-plugin/src/main/resources/org/sonar/plugins/android/lint/java-model.xml
TODO - I think this profile is automatically included if lint report path property is specified
- On a Maven project
- mvn sonar:sonar -Dsonar.profile="Android Lint" in your project
- On another project using sonar-runner
- Add this property to your sonar-project.properties -> sonar.profile=Android Lint
- Apply PR from original repository with updated lint rules
- Update dependencies
- Clean up code
- Check compatibility with newer versions of SonarQube
- Check if we can detach from the SonarJava plugin to become standalone
- Create a sample project
- Integrate with a build server and SonarCloud
- Include the
lint-rules-gen
module