jacoco-android-gradle-plugin icon indicating copy to clipboard operation
jacoco-android-gradle-plugin copied to clipboard

When are we supporting gradle distribution gradle-6.1.1

Open elye opened this issue 5 years ago • 12 comments

Currently gradle sync will fail stating Cannot set the value of read-only property 'executionData' for task ':app:jacocoTestInternalDebugUnitTestReport' of type org.gradle.testing.jacoco.tasks.JacocoReport. when upgrade to gradle-6.1.1

elye avatar Jun 19 '20 08:06 elye

I didn't see it documented anywhere, but a bunch of blog posts and stackoverflow answers pointed me at replacing executionData = fileTree(...) with executionData.from fileTree(...) or alternatively .setFrom (...). I haven't dug deeper yet, but both replacement variants work for me with Gradle plugin 6.1.1 and above

michpohl avatar Jun 22 '20 08:06 michpohl

The same issue. AndroidStudio is ready for 6.1.1 for already some time.

elevenetc avatar Jun 25 '20 14:06 elevenetc

Yes, please update to gradle 6.1.1

userdimi avatar Jul 02 '20 19:07 userdimi

Gradle upgrade says clearly what changed for Jacoco: https://docs.gradle.org/current/userguide/upgrading_version_5.html#other_deprecated_behaviors_and_apis

theonlyjakobob avatar Jul 13 '20 11:07 theonlyjakobob

Apparently, on the class JacocoAndroidPlugin, line 73, this reportTask.executionData.setFrom(project.files(executionData)) should be replaced by reportTask.getExecutionData().setFrom(project.files(executionData))

alexis-morillo avatar Jul 17 '20 09:07 alexis-morillo

Hi guys, you can use 0.1.5-SNAPSHOT. It works fine because fixed in snapshot version. @arturdm could you please release it as stable in order to fix the problem for latest gradle?

lion4ik avatar Jul 17 '20 14:07 lion4ik

@lion4ik I don't find this version :/

uziasferreirazup avatar Jul 17 '20 17:07 uziasferreirazup

You can use https://plugins.gradle.org/plugin/com.hiya.jacoco-android as a temp solution till jacoco-android-gradle-plugin support 6.1.1. It is a fork fixes the issue by @autonomousapps. These are the required changes
https://github.com/ryoyakawai/uitest_sample_android/commit/0982e46f02354f1dbaad4d8ec035bfc04f407dfa

mohamed-khalifa avatar Jul 18 '20 22:07 mohamed-khalifa

Would it be possible to have a released version ?

alexis-morillo avatar Jul 21 '20 16:07 alexis-morillo

I have made my fork open source (apologies for somehow missing this earlier). Obviously this repo is no longer maintained. https://github.com/hiyainc-oss/android-jacoco

autonomousapps avatar Jul 21 '20 19:07 autonomousapps

@lion4ik I don't find this version :/

try this way:

buildscript {
  repositories {
  
    maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
  }
  dependencies {
  
    classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5-SNAPSHOT'
  }
}

It worked for me.

lion4ik avatar Jul 28 '20 15:07 lion4ik

Since Artur is not updating this plugin, I decided to go with another solution following this tutorial -> https://www.rallyhealth.com/coding/code-coverage-for-android-testing (took me like 20 minutes)

Basically, what you need to do is remove this plugin and use Jacoco plugin directly, and then just add task jacocoUnitTestReport to your app's gradle file (You'll find it in the tutorial above).

Anyway just follow the tutorial, but notice - it's a bit outdated, so you will have to remove this line from that jacocoUnitTestReport task $buildDir = // Location of the build directory for the build Variant and also, use classDirectories.from = ..., additionalSourceDirs.from =... etc. instead of classDirectories = ... since it's deprecated.

ivanTrogrlic avatar Aug 27 '20 07:08 ivanTrogrlic