mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-01-31 17:34:48 +01:00
Fix Jacoco under Gradle 7.0,
by migrating the task to use "Task Configuration Avoidance" see https://docs.gradle.org/current/userguide/task_configuration_avoidance.html
This commit is contained in:
parent
75bcbd97b1
commit
af304cd10f
@ -6,7 +6,7 @@ jacoco {
|
|||||||
|
|
||||||
def mergedJacocoExec = file("${project.buildDir}/jacoco/jacocoMerged.exec")
|
def mergedJacocoExec = file("${project.buildDir}/jacoco/jacocoMerged.exec")
|
||||||
|
|
||||||
tasks.create(name: 'jacocoMergeReports', type: JacocoMerge) {
|
def merge = tasks.register('jacocoMergeReports', JacocoMerge) {
|
||||||
group = "Reporting"
|
group = "Reporting"
|
||||||
description = "Merge all jacoco reports from projects into one."
|
description = "Merge all jacoco reports from projects into one."
|
||||||
|
|
||||||
@ -27,7 +27,8 @@ tasks.create(name: 'jacocoMergeReports', type: JacocoMerge) {
|
|||||||
destinationFile(mergedJacocoExec)
|
destinationFile(mergedJacocoExec)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.create(name: 'jacocoFullReport', type: JacocoReport, dependsOn: 'jacocoMergeReports') {
|
tasks.register('jacocoFullReport', JacocoReport) {
|
||||||
|
dependsOn merge
|
||||||
group = "Reporting"
|
group = "Reporting"
|
||||||
description = "Generate full Jacoco coverage report including all modules."
|
description = "Generate full Jacoco coverage report including all modules."
|
||||||
|
|
||||||
@ -46,47 +47,46 @@ tasks.create(name: 'jacocoFullReport', type: JacocoReport, dependsOn: 'jacocoMer
|
|||||||
// Task will run anyway even if initial inputs are empty
|
// Task will run anyway even if initial inputs are empty
|
||||||
onlyIf = { true }
|
onlyIf = { true }
|
||||||
|
|
||||||
doFirst {
|
project.subprojects { subproject ->
|
||||||
project.subprojects { subproject ->
|
subproject.plugins.withId("jacoco") {
|
||||||
subproject.plugins.withId("jacoco") {
|
project.logger.info("${subproject.name} has Jacoco plugin applied")
|
||||||
project.logger.info("${subproject.name} has Jacoco plugin applied")
|
subproject.plugins.withId("kotlin-android") {
|
||||||
subproject.plugins.withId("kotlin-android") {
|
project.logger.info("${subproject.name} is android project")
|
||||||
project.logger.info("${subproject.name} is android project")
|
def mainSources = subproject.extensions.findByName("android").sourceSets['main']
|
||||||
def mainSources = subproject.extensions.findByName("android").sourceSets['main']
|
project.logger.info("Android sources: ${mainSources.java.srcDirs}")
|
||||||
project.logger.info("Android sources: ${mainSources.java.srcDirs}")
|
mainSources.java.srcDirs.forEach {
|
||||||
mainSources.java.srcDirs.forEach {
|
additionalSourceDirs(it)
|
||||||
additionalSourceDirs(it)
|
|
||||||
}
|
|
||||||
project.logger.info("Subproject exclude: ${subproject.jacocoExclude}")
|
|
||||||
additionalClassDirs(fileTree(
|
|
||||||
dir: "${subproject.buildDir}/tmp/kotlin-classes/debug",
|
|
||||||
excludes: subproject.jacocoExclude
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
subproject.plugins.withId("kotlin") { plugin ->
|
project.logger.info("Subproject exclude: ${subproject.jacocoExclude}")
|
||||||
project.logger.info("${subproject.name} is common kotlin project")
|
additionalClassDirs(fileTree(
|
||||||
SourceDirectorySet mainSources = subproject.extensions.getByName("kotlin")
|
dir: "${subproject.buildDir}/tmp/kotlin-classes/debug",
|
||||||
.sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]
|
excludes: subproject.jacocoExclude
|
||||||
.kotlin
|
))
|
||||||
mainSources.srcDirs.forEach {
|
}
|
||||||
project.logger.debug("Adding sources: $it")
|
subproject.plugins.withId("kotlin") { plugin ->
|
||||||
additionalSourceDirs(it)
|
project.logger.info("${subproject.name} is common kotlin project")
|
||||||
}
|
SourceDirectorySet mainSources = subproject.extensions.getByName("kotlin")
|
||||||
project.logger.info("Subproject exclude: ${subproject.jacocoExclude}")
|
.sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]
|
||||||
additionalClassDirs(fileTree(
|
.kotlin
|
||||||
dir: "${subproject.buildDir}/classes/kotlin/main",
|
mainSources.srcDirs.forEach {
|
||||||
excludes: subproject.jacocoExclude
|
project.logger.debug("Adding sources: $it")
|
||||||
))
|
additionalSourceDirs(it)
|
||||||
}
|
}
|
||||||
|
project.logger.info("Subproject exclude: ${subproject.jacocoExclude}")
|
||||||
|
additionalClassDirs(fileTree(
|
||||||
|
dir: "${subproject.buildDir}/classes/kotlin/main",
|
||||||
|
excludes: subproject.jacocoExclude
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
subproject.tasks.withType(Test) { task ->
|
subproject.tasks.withType(Test) { task ->
|
||||||
File destFile = task.extensions.getByType(JacocoTaskExtension.class).destinationFile
|
File destFile = task.extensions.getByType(JacocoTaskExtension.class).destinationFile
|
||||||
if (destFile.exists() && !task.name.contains("Release")) {
|
if (destFile.exists() && !task.name.contains("Release")) {
|
||||||
project.logger.info("Adding execution data: $destFile")
|
project.logger.info("Adding execution data: $destFile")
|
||||||
executionData(destFile)
|
executionData(destFile)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user