Gradle 跳过 jacoco 覆盖插件
Gradle skipping jacoco coverage plugin
我知道在 stackexchange 上有很多类似的问题,但这让我发疯,任何其他答案都没有帮助我。我已经使用了我能找到的 gradle 的几乎所有强制标志。
我的Gradle版本是2.2.1
我的build.gradle
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("se.transmode.gradle:gradle-docker:1.2")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'docker'
apply plugin: 'jacoco'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext {
springCloudVersion = 'Dalston.RELEASE'
}
test {
include 'src/test/java'
finalizedBy jacocoTestReport
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
xml.destination "${buildDir}/jacoco"
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
当我 运行 gradle test
或 gradle clean test jacocoTestReport
或 gradle clean --re-run
等我得到相同的结果。
gradle test
:compileJava
:processResources
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test UP-TO-DATE
:jacocoTestReport SKIPPED
我在 src/test/java 位置只有 1 个测试。
为什么不生成报告和 运行?我很茫然。
删除测试配置中的错误包含语句。
这似乎导致测试任务始终是最新的(不执行任何测试,因为包含模式不匹配)
如果没有生成报告所需的 execution data
,将跳过 jacocoTestReport
。 execution data
应该在执行 test
任务时生成。在您的示例中,我们看到 test
任务始终标记为最新(因为 include 语句无效)导致构建永远不会为 jacocoTestReport
任务生成任何输入。
对于 Spring 2.5 用户,他们坚持了几个小时 -就像我自己。
我没有生成 exec 文件。
正因为如此,
我发现 jacocoTestReport 只是“skipped”。
我通过添加修复了它:
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
那是因为我正在使用 Junit5 和 spring 启动 2.X
我知道在 stackexchange 上有很多类似的问题,但这让我发疯,任何其他答案都没有帮助我。我已经使用了我能找到的 gradle 的几乎所有强制标志。
我的Gradle版本是2.2.1
我的build.gradle
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("se.transmode.gradle:gradle-docker:1.2")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'docker'
apply plugin: 'jacoco'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext {
springCloudVersion = 'Dalston.RELEASE'
}
test {
include 'src/test/java'
finalizedBy jacocoTestReport
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
xml.destination "${buildDir}/jacoco"
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
当我 运行 gradle test
或 gradle clean test jacocoTestReport
或 gradle clean --re-run
等我得到相同的结果。
gradle test
:compileJava
:processResources
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test UP-TO-DATE
:jacocoTestReport SKIPPED
我在 src/test/java 位置只有 1 个测试。
为什么不生成报告和 运行?我很茫然。
删除测试配置中的错误包含语句。
这似乎导致测试任务始终是最新的(不执行任何测试,因为包含模式不匹配)
如果没有生成报告所需的 execution data
,将跳过 jacocoTestReport
。 execution data
应该在执行 test
任务时生成。在您的示例中,我们看到 test
任务始终标记为最新(因为 include 语句无效)导致构建永远不会为 jacocoTestReport
任务生成任何输入。
对于 Spring 2.5 用户,他们坚持了几个小时 -就像我自己。
我没有生成 exec 文件。
正因为如此,
我发现 jacocoTestReport 只是“skipped”。
我通过添加修复了它:
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
那是因为我正在使用 Junit5 和 spring 启动 2.X