@@ -12,13 +12,24 @@ buildscript {
1212}
1313
1414plugins {
15- id ' nebula.optional-base' version ' 3.2.0'
15+ id ' com.github.kt3k.coveralls' version ' 2.8.2'
16+ id ' jacoco'
1617 id ' me.champeau.gradle.jmh' version ' 0.3.1'
18+ id ' nebula.optional-base' version ' 3.2.0'
1719}
1820
1921allprojects {
2022 group = ' com.optimizely.ab'
2123 apply plugin : ' idea'
24+ apply plugin : ' jacoco'
25+
26+ repositories {
27+ jcenter()
28+ }
29+
30+ jacoco {
31+ toolVersion = ' 0.8.0'
32+ }
2233}
2334
2435apply from : ' gradle/publish.gradle'
@@ -33,8 +44,8 @@ allprojects {
3344subprojects {
3445 apply plugin : ' com.jfrog.bintray'
3546 apply plugin : ' findbugs'
36- apply plugin : ' java'
3747 apply plugin : ' jacoco'
48+ apply plugin : ' java'
3849 apply plugin : ' maven-publish'
3950 apply plugin : ' me.champeau.gradle.jmh'
4051 apply plugin : ' nebula.optional-base'
@@ -170,9 +181,49 @@ subprojects {
170181 task ship() {
171182 dependsOn(' bintrayUpload' )
172183 }
184+
173185}
174186
175187task ship () {
176188 dependsOn(' :core-api:ship' , ' :core-httpclient-impl:ship' )
177189}
178190
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