jacoco-android-gradle-plugin
                                
                                
                                
                                    jacoco-android-gradle-plugin copied to clipboard
                            
                            
                            
                        Fixed build crash in gradle 8.0
closes: https://github.com/arturdm/jacoco-android-gradle-plugin/issues/102
Updated the jacocoTestReport properties from enabled to required as mentioned by Gradle documentation for plugin.
I tested the project builds on both Gradle 7.0.2 (current version in master) and Gradle 8.0.
@kevalpatel2106 Thank you so much for this PR, it helps me get my own fork working. But one question, shouldn't line 88 to 101 in JacocoAndroidPlugin.groovy also be updated? The way it is now you still set the property on the plugin, right?
csv.enabled project.jacocoAndroidUnitTestReport.csv.enabled
html.enabled project.jacocoAndroidUnitTestReport.html.enabled
xml.enabled project.jacocoAndroidUnitTestReport.xml.enabled
                                    
                                    
                                    
                                
@avalanchas Thanks for the feedback. This is my first time working with Gradle Plugin, so please bare me here.
I am making the following changes to reportTask
    reportTask.reports {
      def destination = project.jacocoAndroidUnitTestReport.destination
      
      csv.required project.jacocoAndroidUnitTestReport.csv.enabled
      html.required project.jacocoAndroidUnitTestReport.html.enabled
      xml.required project.jacocoAndroidUnitTestReport.xml.enabled
      if (csv.enabled) {
        csv.outputLocation new File((destination == null) ? "${project.buildDir}/jacoco/jacoco.csv" : "${destination.trim()}/jacoco.csv")
      }
      
      if (html.enabled) {
        html.outputLocation new File((destination == null) ? "${project.buildDir}/jacoco/jacocoHtml" : "${destination.trim()}/jacocoHtml")
      }
      if (xml.enabled) {
        xml.outputLocation new File((destination == null) ? "${project.buildDir}/jacoco/jacoco.xml" : "${destination.trim()}/jacoco.xml")
      }
    }
I also found that Report.destination is also deprecated and replaced with getOutputLocation. (So, I did something similar to this)
Does it look correct?
I tried running ./gradlew jacocoTestReport as mentioned in the readme and the task passed without these changes. Now I doubt the tasks did anything or not. Do you have any better method to test whether the merged reports are actually being generated?
Very nice that we can work together on this, I am also pretty new to this. Yes that looks correct to me, since ReportConfiguration still names the field enabled, so that should compile.
I was also just compiling this on a fork a second ago and saw that destination is crashing. I simply removed it to get it working but your solution is of course much better. I did not notice getOutputLocation before, is there any documentation for the migration you could link?
Hope that this can be merged soon
Documentation for getOutputLocation: https://docs.gradle.org/current/javadoc/org/gradle/api/reporting/DirectoryReport.html#getOutputLocation--
I couldn't find the migration doc, but this was a warning message was there before Gradle 8.0.
@avalanchas Pushed new changes.
@arturdm Can you take a look at this PR? As the Gradle 8 adoption increases in the Android project, I think we will start getting more and more issues about plugin failing the build. I suggest we treat it as an urgent fix.
As I said above, very new to gradle plugins. So, happy to hear any suggestions.
@kevalpatel2106 Are you planning to take over maintenance and to publish your fork on Maven Central?
@kevalpatel2106 I applied your fork, but still I have:
by: org.codehaus.groovy.runtime.metaclass.MissingMethodExecutionFailed: No signature of method: org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport.required() is applicable for argument types: (Boolean) values: [false]
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method required() for arguments [false] on Report csv of type org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport.
	at org.gradle.internal.metaobject.AbstractDynamicObject$CustomMissingMethodExecutionFailed.<init>(AbstractDynamicObject.java:190)
	at org.gradle.internal.metaobject.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:184)
	at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:167)
	at org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport_Decorated.invokeMethod(Unknown Source)
	at io.github.kevalpatel2106.gradle.jacoco.android.JacocoAndroidPlugin$_createReportTask_closure2.doCall(JacocoAndroidPlugin.groovy:88)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.gradle.util.internal.ClosureBackedAction.execute(ClosureBackedAction.java:73)
	at org.gradle.util.internal.ConfigureUtil.configureTarget(ConfigureUtil.java:155)
	at org.gradle.util.internal.ConfigureUtil.configureSelf(ConfigureUtil.java:131)
	at org.gradle.api.reporting.internal.DefaultReportContainer.configure(DefaultReportContainer.java:61)
	at org.gradle.api.reporting.internal.DefaultReportContainer.configure(DefaultReportContainer.java:35)
	at org.gradle.util.internal.ClosureBackedAction.execute(ClosureBackedAction.java:65)
	at org.gradle.testing.jacoco.tasks.JacocoReport.reports(JacocoReport.java:77)
	at org.gradle.testing.jacoco.tasks.JacocoReport.reports(JacocoReport.java:72)
	at org.gradle.testing.jacoco.tasks.JacocoReport.reports(JacocoReport.java:35)
	at org.gradle.api.reporting.Reporting$reports.call(Unknown Source)
	at 
------------------------------------------------------------
Gradle 8.0
------------------------------------------------------------
Build time:   2023-02-13 13:15:21 UTC
Revision:     62ab9b7c7f884426cf79fbedcf07658b2dbe9e97
Kotlin:       1.8.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.19 (Oracle Corporation 11.0.19+7)
OS:           Linux 6.2.11-arch1-1 amd64
                                    
                                    
                                    
                                
Hello folks 👋 Is this repo abandoned, or can we hope this fix will be merged?
Thanks.