Setup SonarQube for Android

Intro

Sonarqube is static code analyzer tool on server side. It is very useful to write clean and quality code.

This tutorial is going to setup SonarQube on local and config scanner in Android project.

Installation

Setup SonarQube

  • Login by admin:admin

SonarQube already provided build-in Quality Gates called “Sonar way”.

You can install more plug-in in Administration page.

Config project scanner

  • Open build.gradle(app) and add: ``` apply plugin: “org.sonarqube”

… sonarqube { properties { property “sonar.projectName”, “{PROJECT_NAME}” property “sonar.projectKey”, “{PACKAGE_NAME}” property “sonar.host.url”, “http://localhost:9000” property “sonar.login”, “{LOGIN_NAME}” property “sonar.password”, “{LOGIN_PASSWORD}” property “sonar.language”, “java” property “sonar.sources”, “src/main/java” } }


- Open build.gradle(project) and add:

dependencies { … classpath “org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1” } ```

Run scan task

  • Open terminal and run gradlew sonarqube to start scanning.
  • Project will be created automatically on SonarQube.
  • Open http://localhost:9000 to see the report
Written on March 13, 2019