@@ -18,7 +18,6 @@ import org.neotech.plugin.rootcoverage.utilities.afterAndroidPluginApplied
1818import org.neotech.plugin.rootcoverage.utilities.assertMinimumRequiredAGPVersion
1919import org.neotech.plugin.rootcoverage.utilities.fileTree
2020import org.neotech.plugin.rootcoverage.utilities.onVariant
21- import org.neotech.plugin.rootcoverage.utilities.getReportOutputFile
2221import java.io.File
2322
2423class RootCoveragePlugin : Plugin <Project > {
@@ -53,30 +52,23 @@ class RootCoveragePlugin : Plugin<Project> {
5352
5453
5554 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()
5762 task.addSubProject(task.project)
5863 }
5964
6065 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+ )
8072
8173 project.allprojects.forEach { subProject ->
8274 subProject.assertAndroidCodeCoverageVariantExists()
0 commit comments