@@ -18,7 +18,6 @@ import org.neotech.plugin.rootcoverage.utilities.afterAndroidPluginApplied
18
18
import org.neotech.plugin.rootcoverage.utilities.assertMinimumRequiredAGPVersion
19
19
import org.neotech.plugin.rootcoverage.utilities.fileTree
20
20
import org.neotech.plugin.rootcoverage.utilities.onVariant
21
- import org.neotech.plugin.rootcoverage.utilities.getReportOutputFile
22
21
import java.io.File
23
22
24
23
class RootCoveragePlugin : Plugin <Project > {
@@ -53,30 +52,23 @@ class RootCoveragePlugin : Plugin<Project> {
53
52
54
53
55
54
private fun createSubProjectCoverageTask (subProject : Project ) {
56
- val task = subProject.createJacocoReportTask(rootProjectExtension)
55
+ val task = subProject.createJacocoReportTask(
56
+ taskName = " coverageReport" ,
57
+ taskGroup = " reporting" ,
58
+ taskDescription = " Generates a Jacoco for this Gradle module." ,
59
+ rootProjectExtension = rootProjectExtension
60
+ )
61
+ // subProject.assertAndroidCodeCoverageVariantExists()
57
62
task.addSubProject(task.project)
58
63
}
59
64
60
65
private fun createCoverageTaskForRoot (project : Project ) {
61
- val task = project.tasks.create(" rootCoverageReport" , JacocoReport ::class .java)
62
-
63
- // Make sure to only read from the rootProjectExtension after the project has been evaluated
64
- project.afterEvaluate {
65
- task.reports.html.required.set(rootProjectExtension.generateHtml)
66
- task.reports.xml.required.set(rootProjectExtension.generateXml)
67
- task.reports.csv.required.set(rootProjectExtension.generateCsv)
68
- }
69
-
70
- // Make sure to configure this JacocoReport task after the JaCoCoPlugin itself has been fully applied, otherwise the JaCoCoPlugin
71
- // may override settings in configureJacocoReportsDefaults()
72
- // https://github.com/gradle/gradle/blob/c177053ff95a1582c7919befe67993e0f1677f53/subprojects/jacoco/src/main/java/org/gradle/testing/jacoco/plugins/JacocoPlugin.java#L211
73
- project.pluginManager.withPlugin(" jacoco" ) {
74
- task.group = " reporting"
75
- task.description = " Generates a Jacoco report with combined results from all the subprojects."
76
- task.reports.html.outputLocation.set(project.getReportOutputFile(" jacoco" ))
77
- task.reports.xml.outputLocation.set(project.getReportOutputFile(" jacoco.xml" ))
78
- task.reports.csv.outputLocation.set(project.getReportOutputFile(" jacoco.csv" ))
79
- }
66
+ val task = project.createJacocoReportTask(
67
+ taskName = " rootCoverageReport" ,
68
+ taskGroup = " reporting" ,
69
+ taskDescription = " Generates a Jacoco report with combined results from all the subprojects." ,
70
+ rootProjectExtension = rootProjectExtension
71
+ )
80
72
81
73
project.allprojects.forEach { subProject ->
82
74
subProject.assertAndroidCodeCoverageVariantExists()
0 commit comments