2017-06-14 198 views
0

我知道这对stackexchange有很多类似的问题,但这使我疯狂,没有任何其他答案对我有帮助。我已经使用了几乎所有的力量标志来寻找Gradle。Gradle跳过jacoco覆盖插件

我的摇篮版本是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 testgradle clean test jacocoTestReportgradle clean --re-run等等等等,我得到了相同的结果。

gradle test 
:compileJava 
:processResources 
:classes 
:compileTestJava 
:processTestResources UP-TO-DATE 
:testClasses 
:test UP-TO-DATE 
:jacocoTestReport SKIPPED 

我在src/test/java位置只有1个测试。

为什么不生成报告并运行?我很茫然。

回答

0

删除测试配置中的错误include语句。

这似乎导致测试任务始终采用最新的(不执行任何测试的包括模式不匹配),如果没有可用execution data所需要

jacocoTestReport将被跳过生成报告。在执行test任务时应生成execution data。在您的示例中,我们看到test任务始终标记为最新(因为include语句无效),导致构建不会为jacocoTestReport任务生成任何输入。

+1

谢谢!这包括从我看到的另一个例子中“借来的”,并且我不理解其中的原因。学过的知识! – Justin