Skip to content

Commit 370fceb

Browse files
authored
integrate coveralls (#169)
* add coveralls gradle plugin from to build.gradle * use jacoco. refresh gradle wrapper * upgrade to jacoco version 0.8.0 * try stuff from caffeine gradle
1 parent 71280f5 commit 370fceb

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ branches:
2222
only:
2323
- master
2424
- /^\d+\.\d+\.\d+(-SNAPSHOT|-alpha|-beta)?\d*$/ # trigger builds on tags which are semantically versioned to ship the SDK.
25+
after_success:
26+
- ./gradlew coveralls uploadArchives --console plain

build.gradle

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,24 @@ buildscript {
1212
}
1313

1414
plugins {
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

1921
allprojects {
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

2435
apply from: 'gradle/publish.gradle'
@@ -33,8 +44,8 @@ allprojects {
3344
subprojects {
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

175187
task 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+
}

gradle/wrapper/gradle-wrapper.jar

4 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip

0 commit comments

Comments
 (0)