Gradle jacoco coverage report with more than one submodule(s)?

后端 未结 5 1564
攒了一身酷
攒了一身酷 2021-01-02 11:35

Does anybody know how to configure a gradle file for java jacoco report that contain codecoverage of more than one gradle submodule?

my current approach only shows c

5条回答
  •  抹茶落季
    2021-01-02 12:14

    You can create a merged report without merged exec file. Create a new task to the root of build.gradle with following content.

    task jacocoReport(type: JacocoReport) {
        for (p in allprojects) {
            def testTask = p.tasks.findByName("test")
            if (testTask != null)
                dependsOn(testTask)
    
            executionData.setFrom(file("${p.buildDir}/jacoco/test.exec"))
            classDirectories.from(file("${p.buildDir}/classes/java/main"))
        }
    }
    

提交回复
热议问题