-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsonarqube.gradle
74 lines (69 loc) · 2.96 KB
/
sonarqube.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// recommend to specify the flavor once and dynamically adapt paths to it
//def flavor = "develop" // flavor we want to have tested. Should be static
//def Flavor = "Develop" // flavor again, but starting with upper case
// noinspection is used to remove some "warnings" from Android Studio
sonarqube {
//noinspection GroovyAssignabilityCheck
androidVariant 'debug'
properties {
def libraries = project.android.sdkDirectory.getPath() + "/platforms/android-30/android.jar," +
"build/intermediates/**/classes.jar"
property "sonar.host.url", "http://sonarqube.mcruncher.com"
property "sonar.projectName", "WORSHIPSONGS::ANDROID"
property "sonar.projectKey", "org.worshipsongs"
property "sonar.profile", "Android java"
property "sonar.projectVersion", AppVersion
property "sonar.sourceEncoding", "UTF-8"
property "sonar.sources", "src/main/java,src/main/res"
property "sonar.binaries", "build/tmp/kotlin-classes/debug"
property "sonar.libraries", libraries
property "sonar.java.binaries", "build/tmp/kotlin-classes/debug"
property "sonar.java.libraries", libraries
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.android.lint.report", "build/reports/lint-results-debug.xml"
property "sonar.jacoco.reportPath", "build/jacoco/testDebugUnitTest.exec"
property "sonar.junit.reportsPath", "build/test-results/testDebugUnitTest"
}
}
import org.gradle.internal.os.OperatingSystem;
task sonarComplete(type: Exec) {
workingDir "./"
def command = "../gradlew"
if (OperatingSystem.current().isWindows()) {
command = command + ".bat"
}
commandLine command, "clean", "assembleDebug", "lintDebug", "jacocoTestDebugUnitTestReport", "sonarqube"
}
jacoco {
// https://github.com/jacoco/jacoco/issues/288
toolVersion = "0.7.9"
}
def coverageSourceDirs = ['../app/src/main/java']
task jacocoAndroidUnitTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
group = "Reporting"
description = "Generate Jacoco coverage reports"
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(
dir: '../app/build/tmp/kotlin-classes',
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/BuildConfig.*',
'**/Manifest*.*', '**/**Test*']
)
}))
additionalSourceDirs.setFrom(files(coverageSourceDirs))
sourceDirectories.setFrom(files(coverageSourceDirs))
executionData.setFrom(files('../app/build/jacoco/testDebugUnitTest.exec'))
reports {
xml.enabled = true
html.enabled = true
}
doFirst {
files('build/tmp/kotlin-classes/debug').getFiles().each { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}