Gradle configuration in Android Studio sonarqube

Source: Internet
Author: User

Sonarqube is used as a useful static code analysis tool in many projects. Android Nature is no exception. Share here how to configure Sonarqube in Gradle when using Android Studio.

The following are simply described using both public maven repositories and private maven repositories:

One, use a public maven repository:

This is relatively simple.

Open Gradle Sonarqube Plugin official website:

You can see that there are two ways to integrate the Sonarqube plug-in, and you can choose the right way:

1: All Gradle plugin versions are available:

Buildscript {  repositories {    maven {      url ""    }  }  dependencies {    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2"  }}apply plugin: "Org.sonarqube"

2:gradle Plugin version 2.1 above applies:

Plugins {  id "org.sonarqube" version "2.2"}

Second, use a private maven repository:

The 2nd method above is not available, because writing Gradle will think of it as core plugin, which is resolved by default to

We open this URL in the browser, we will find that it is a JSON:

{  "id": "org.sonarqube",  "version": "2.2",  "Implementation": {    "Gav": " org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2 ",    " repo ":" Https:// "  },  "Implementationtype": "M2_jar",  "Legacy": true}

found that it is in the according to the "Org.sonarqube" this ID to find the appropriate plug-in, and we need to find a plugin in their own repository, obviously this is not appropriate.

Therefore, you can only use the 1th method above:

Add this paragraph to the module's build.gradle, plus the task:

Sonarqube {        Properties {property              ' sonar.sources ', ' src ' property              ' ', ' build/ Intermediates/classes "Property              " Sonar.test.binaries "," build/intermediates/classes "...              //  Join the configuration you need        }}    

So when you're ready to configure your sonar host:


Gradle Sonarqube

Wait a moment, and when the build successfully appears, you'll see the code on Sonar portal.

Gradle configuration in Android Studio sonarqube

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.