1. Download SonarQube from following link v 6.6.7
2. Now Open your terminal and go to your downloaded sonarQube folder:
for example u are on root like:-
SupriyaMac:~ SupriyaBharti$ cd Downloads/sonarqube-6.7.6/bin/macosx-universal-64/
SupriyaMac:macosx-universal-64 SupriyaBharti$ ./sonar.sh start
Starting SonarQube...
SonarQube is already running.
Images:-
3. Now time to open sonar local host in your browser , please copy paste below link in your web browser:-
4. Open your android studio project and open the project build.gradle and add following :-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1' // added for sonarQube
}
Images :-
5. Now open app build.gradle and add following :-
apply plugin: 'org.sonarqube' // added for sonar qube
// added for sonar qube
sonarqube {
properties {
property "sonar.projectName", "ContentResolver"
property "sonar.projectKey", "ContentResolver"
property "sonar.language", "java"
property "sonar.sources", "src/main/java"
property "sonar.java.sources", "src/main/java"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.login", "admin"
property "sonar.password", "admin"
}
}
Note :- Here in sonarQube property "sonar.sources", "src/main/java" this source path is very important .
Images :-
Note :- put sonar properties above dependencies.
6. Now open your terminal inside android studio
check you are at you current project root like for me my current project location will looks like following :-
SupriyaMac:ContentResolver SupriyaBharti$
7. Now run following command :
NOTE : no 7 is very important if you will not run this command than u will not able to connect your project with sonarLocal host.
8. Finally your refresh sonarQube local host and it will look look following :-
Images:-
For End to End sonar Qube integration you can also watch my youtube video :
https://www.youtube.com/watch?v=AjoI7EvVgMQ&t=4s