我正在尝试排除多模块Sping Boot 项目中的一些文件。我尝试在test中使用JaCoCo的excludes扩展,并在jacocoTestReport中添加afterEvaluate块。这两个选项都不起作用。Gradle版本是8.1.1,Sping Boot 版本是3.1.2。有人能帮助我吗?下面是主gradle文件:
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
plugins {
id "org.sonarqube" version "4.2.1.3168"
}
group = "${group}"
version = "${version}"
subprojects {
apply {
plugin "java"
plugin "org.springframework.boot"
plugin "io.spring.dependency-management"
plugin 'jacoco-report-aggregation'
}
java {
sourceCompatibility = JavaVersion.VERSION_17
}
dependencies {
//removed for brevity
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
tasks.named('test') {
useJUnitPlatform()
// jacoco {
// excludes = [
// "**/config**"
// ]
// }
}
bootJar {
enabled = false
}
jacoco {
toolVersion = "${jacocoVersion}" //0.8.9
}
jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.required = true
}
}
jacocoTestReport {
dependsOn test
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"**/config**"
])
}))
}
}
}
字符串
1条答案
按热度按时间daupos2t1#
我添加了一个
testCodeCoverageReport
和jacocoTestCoverageVerification
任务到build.gradle
,它现在工作正常。我还将这个配置移到了包含我的测试用例和main方法的模块中。
更新jacoco配置:
字符串