-
Notifications
You must be signed in to change notification settings - Fork 115
/
build.gradle
128 lines (110 loc) · 3.52 KB
/
build.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
buildscript {
apply from: 'deps.gradle'
repositories {
google()
jcenter()
}
dependencies {
classpath deps.android_plugin
classpath deps.kotlin_plugin
classpath deps.coverallPlugin
classpath deps.spotlessPlugin
classpath deps.dokkaPlugin
}
}
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
repositories {
jcenter()
}
//from https://gist.github.com/aalmiray/e6f54aa4b3803be0bcac
task jacocoTestReport {
doLast {
FileCollection executionData = files()
subprojects.findAll { subproject ->
subproject.pluginManager.hasPlugin('java') && subproject.pluginManager.hasPlugin('jacoco')
}.each { subproject -> executionData += subproject.tasks.jacocoTestReport.executionData
}
executionData = files(executionData.findAll {
it.exists()
})
ant.taskdef(name: 'jacocoReport', classname: 'org.jacoco.ant.ReportTask',
classpath: configurations.jacocoAnt.asPath)
ant.jacocoReport {
executiondata {
executionData.addToAntBuilder(ant, 'resources')
}
structure(name: project.name) {
subprojects.findAll { subproject -> subproject.pluginManager.hasPlugin('java')
}.each { subproject ->
group(name: subproject.name) {
classfiles {
((FileCollection) subproject.sourceSets.main.output).filter {
it.exists()
}.addToAntBuilder(ant, 'resources')
}
sourcefiles {
files((Set<File>) subproject.sourceSets.main.allJava.srcDirs).filter {
it.exists()
}.addToAntBuilder(ant, 'resources')
}
}
}
}
html(destdir: "${buildDir}/reports/jacoco/${name}/html")
xml(destfile: "${buildDir}/reports/jacoco/${name}/${name}.xml")
// Uncomment for CSV
//csv(destfile: "${buildDir}/reports/jacoco/${name}/${name}.csv")
}
}
}
coveralls {
jacocoReportPath = 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml'
sourceDirs = files(subprojects.collect { subproject -> "${subproject.projectDir}/src/main/java" }).files.absolutePath
}
tasks.coveralls {
dependsOn 'jacocoTestReport'
}
subprojects { project ->
group = GROUP
version = VERSION_NAME
repositories {
jcenter()
}
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'com.diffplug.spotless'
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked'
options.deprecation = true
}
spotless {
java {
licenseHeaderFile rootProject.file('spotless.license.java.txt')
googleJavaFormat() // use a specific formatter for Java files
target '**/*.java'
}
kotlin {
// optionally takes a version
ktlint().userData(['indent_size': '2'])
target '**/*.kt'
// also supports license headers
licenseHeaderFile rootProject.file('spotless.license.java.txt')
}
}
afterEvaluate {
if (project.tasks.findByName('check') && project.pluginManager.hasPlugin('java')) {
check.dependsOn('spotlessCheck')
check.dependsOn('jacocoTestReport')
tasks.withType(Test) {
testLogging {
events "passed", "skipped", "failed"
}
// ensure tasks don't overwrite the default report directories used by the 'test' task
reports.html.setDestination(new File("${buildDir}/reports/${name}"))
reports.junitXml.setDestination(new File("${buildDir}/reports/${name}/results"))
binResultsDir = file("${buildDir}/reports/${name}/results/binary/${name}")
}
}
}
}