Skip to content

Commit b7ce22b

Browse files
committed
Merge pull request #202 from JLLeitschuh/build/splitProjectCodeCoverageReporting
Fix CodeCov not retriving coverage data
2 parents 8e34f03 + 13daa7f commit b7ce22b

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ addons:
1919
before_install:
2020
- export DISPLAY=:99.0
2121
- sh -e /etc/init.d/xvfb start
22+
- pip install --user codecov
2223

2324
install: ./gradlew :ui:assemble --stacktrace
2425

2526
after_failure: #Run again with debug info enabled
2627
- ./gradlew check --stacktrace -PprintTestResults
2728

2829
after_success:
29-
- bash <(curl -s https://codecov.io/bash) # Code Coverage Reporting
30+
- codecov
3031
- ./gradlew aggregateJavadocs
3132
- .travis-scripts/push-javadoc-to-gh-pages.sh
3233
- .travis-scripts/before-deploy.sh

build.gradle

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ plugins {
1515
}
1616
apply plugin: 'nebula-aggregate-javadocs'
1717

18-
1918
allprojects {
2019
apply plugin: 'java'
2120
apply plugin: 'application'
21+
apply plugin: 'jacoco'
2222

2323

2424
repositories {
@@ -39,6 +39,7 @@ allprojects {
3939
html.enabled = true
4040
}
4141
}
42+
4243
check.dependsOn jacocoTestReport
4344

4445
tasks.withType(Javadoc) {
@@ -170,6 +171,30 @@ project(":ui") {
170171
mainClassName = javafx.mainClass
171172
}
172173

174+
/*
175+
* This is roughly based upon this post:
176+
* https://discuss.gradle.org/t/merge-jacoco-coverage-reports-for-multiproject-setups/12100/6
177+
*/
178+
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
179+
description = 'Generates an aggregate report from all subprojects'
180+
dependsOn(subprojects.test)
181+
182+
additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
183+
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
184+
classDirectories = files(subprojects.sourceSets.main.output)
185+
executionData = files(subprojects.jacocoTestReport.executionData)
186+
187+
reports {
188+
html.enabled = true
189+
xml.enabled = true
190+
}
191+
192+
doFirst {
193+
executionData = files(executionData.findAll { it.exists() })
194+
}
195+
}
196+
check.dependsOn jacocoRootReport
197+
173198
task wrapper(type: Wrapper) {
174199
gradleVersion = '2.9'
175200
}

0 commit comments

Comments
 (0)