1. Download sonarqube dari https://www.sonarqube.org/downloads/
2. Extract / unzip
3. Open sonarqube-blablabla/bin
4. Open next folder depend on your platform (in this tutorial I'm using linux)
5. Start sonarqube. open terminal & type => sh sonar.sh start
6. Open http://localhost:9000 on your browser, to see admin panel.
7. Login with username 'admin' & password 'admin'
8. Create new project. Set up project key, display name & token.
9. Setting gradle project
buildscript {
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.1.1"
classpath "com.hiya:jacoco-android:0.2"
}
}
apply plugin: 'com.android.application'
apply plugin: "org.sonarqube"
apply plugin: "com.hiya.jacoco-android"
sonarqube {
properties {
property "sonar.projectKey", "com.fd.analyze" // TODO: - Setup your project key
property "sonar.projectName", "Android Code Analyze" // TODO: - Setup your project name
property "sonar.host.url", "http://localhost:9000/" // TODO: - Setup your server address
property "sonar.login", "bdda7079b9f487809961c88f21b3acf3b2d4d0ec" // TODO: - Setup token
property "sonar.projectVersion", "1.0.0"
property "sonar.exclusions", "robospice/**/*"
property "sonar.sources", "src/main/java"
property "sonar.binaries", "build/intermediates/app_classes/debug"
property "sonar.java.binaries", "build/intermediates/app_classes/debug"
property "sonar.tests", "src/test/java, src/androidTest/java"
property "sonar.java.test.binaries", "build/intermediates/app_classes/debug"
def unit = fileTree(dir: project.projectDir, includes: ['**/*.exec']).files;
def ui = fileTree(dir: project.projectDir, includes: ['**/*.ec']).files;
unit.addAll(ui);
def files = unit.join(", ");
property "sonar.jacoco.reportPaths", files
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.junit.reportsPath", "build/test-results/testDebugUnitTest"
property "sonar.android.lint.report", "build/reports/lint-results.xml"
}
}
10. Execute Task
./gradlew clean connectedAndroidTest test createDebugCoverageReport jacocoTestReport sonarqube
11. See result on sonarqube dashboard
Komentar
Posting Komentar