Skip to content

Commit 2e85d9c

Browse files
committed
Update jacoco configuration
1 parent 358ff80 commit 2e85d9c

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

build.gradle

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ ext {
3737
osgiCompendiumVersion = '5.0.0'
3838
paxExamVersion = '4.12.0'
3939
projectOsgiVersion = project.version.replaceAll("-SNAPSHOT", ".SNAPSHOT")
40+
41+
jacocoTestProjects = [
42+
'camel-ldp-elasticsearch',
43+
'camel-ldp-ldpath',
44+
'camel-ldp-triplestore',
45+
'camel-ldp-websub',
46+
'camel-ldp-osgi'
47+
]
4048
}
4149

4250
allprojects { subproj ->
@@ -279,6 +287,14 @@ subprojects { subproj ->
279287
html.enabled = true
280288
}
281289
}
290+
291+
afterEvaluate {
292+
if (subproj.name in jacocoTestProjects) {
293+
jacoco {
294+
applyTo subproj.tasks.matching { it.name == 'junitPlatformTest' }
295+
}
296+
}
297+
}
282298
}
283299

284300
configure(rootProject) {
@@ -322,18 +338,28 @@ configure(rootProject) {
322338
}
323339
}
324340

325-
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
326-
dependsOn = subprojects.test
327-
additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
328-
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
329-
classDirectories = files(subprojects.sourceSets.main.output)
330-
executionData = files(subprojects.jacocoTestReport.executionData)
331-
reports {
332-
html.enabled = true
333-
xml.enabled = true
334-
csv.enabled = false
335-
}
336-
}
341+
task jacocoMerge(type: JacocoMerge) {
342+
subprojects.findAll { it.name in jacocoTestProjects }
343+
.each { subproj ->
344+
executionData fileTree(dir: "${subproj.buildDir}/jacoco", include: '*.exec')
345+
dependsOn subproj.tasks.withType(Test)
346+
}
347+
}
348+
349+
task jacocoRootReport(type: JacocoReport, dependsOn: jacocoMerge) {
350+
sourceDirectories = files(subprojects
351+
.findAll { it.name in jacocoTestProjects }
352+
.sourceSets.main.allSource.srcDirs)
353+
classDirectories = files(subprojects
354+
.findAll { it.name in jacocoTestProjects }
355+
.sourceSets.main.output)
356+
executionData jacocoMerge.destinationFile
357+
reports {
358+
html.enabled = true
359+
xml.enabled = true
360+
csv.enabled = false
361+
}
362+
}
337363

338364
coveralls {
339365
sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()

0 commit comments

Comments
 (0)