@@ -12,13 +12,24 @@ buildscript {
12
12
}
13
13
14
14
plugins {
15
- id ' nebula.optional-base' version ' 3.2.0'
15
+ id ' com.github.kt3k.coveralls' version ' 2.8.2'
16
+ id ' jacoco'
16
17
id ' me.champeau.gradle.jmh' version ' 0.3.1'
18
+ id ' nebula.optional-base' version ' 3.2.0'
17
19
}
18
20
19
21
allprojects {
20
22
group = ' com.optimizely.ab'
21
23
apply plugin : ' idea'
24
+ apply plugin : ' jacoco'
25
+
26
+ repositories {
27
+ jcenter()
28
+ }
29
+
30
+ jacoco {
31
+ toolVersion = ' 0.8.0'
32
+ }
22
33
}
23
34
24
35
apply from : ' gradle/publish.gradle'
@@ -33,8 +44,8 @@ allprojects {
33
44
subprojects {
34
45
apply plugin : ' com.jfrog.bintray'
35
46
apply plugin : ' findbugs'
36
- apply plugin : ' java'
37
47
apply plugin : ' jacoco'
48
+ apply plugin : ' java'
38
49
apply plugin : ' maven-publish'
39
50
apply plugin : ' me.champeau.gradle.jmh'
40
51
apply plugin : ' nebula.optional-base'
@@ -170,9 +181,49 @@ subprojects {
170
181
task ship() {
171
182
dependsOn(' bintrayUpload' )
172
183
}
184
+
173
185
}
174
186
175
187
task ship () {
176
188
dependsOn(' :core-api:ship' , ' :core-httpclient-impl:ship' )
177
189
}
178
190
191
+ // Only report code coverage for projects that are distributed
192
+ def publishedProjects = subprojects. findAll { it. path != ' :simulator' }
193
+
194
+ task jacocoMerge (type : JacocoMerge ) {
195
+ publishedProjects. each { subproject ->
196
+ executionData subproject. tasks. withType(Test )
197
+ }
198
+ doFirst {
199
+ executionData = files(executionData. findAll { it. exists() })
200
+ }
201
+ }
202
+
203
+ task jacocoRootReport (type : JacocoReport , group : ' Coverage reports' ) {
204
+ description = ' Generates an aggregate report from all subprojects'
205
+ dependsOn publishedProjects. test, jacocoMerge
206
+
207
+ additionalSourceDirs = files(publishedProjects. sourceSets. main. allSource. srcDirs)
208
+ sourceDirectories = files(publishedProjects. sourceSets. main. allSource. srcDirs)
209
+ classDirectories = files(publishedProjects. sourceSets. main. output)
210
+ executionData jacocoMerge. destinationFile
211
+
212
+ reports {
213
+ html. enabled = true // human readable
214
+ xml. enabled = true // required by coveralls
215
+ }
216
+ }
217
+
218
+ coveralls {
219
+ sourceDirs = publishedProjects. sourceSets. main. allSource. srcDirs. flatten()
220
+ jacocoReportPath = " ${ buildDir} /reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
221
+ }
222
+
223
+ tasks. coveralls {
224
+ group = ' Coverage reports'
225
+ description = ' Uploads the aggregated coverage report to Coveralls'
226
+
227
+ dependsOn jacocoRootReport
228
+ onlyIf { System . env. ' CI' && ! JavaVersion . current(). isJava9Compatible() }
229
+ }
0 commit comments