gradle-clover-plugin icon indicating copy to clipboard operation
gradle-clover-plugin copied to clipboard

Issue using com.bmuschko.clover plugin for Android lib (gradle, java)

Open Eugene-Novikov opened this issue 2 years ago • 2 comments

Hi,

Gradle 6.9.1 (gradle wrapper)

After adding plugin to plugins section id 'com.bmuschko.clover' version '3.0.1' apply true

I have an error with stack trace at the end

I tried to check plugin code, but don't understand reason, because of the code:

task checkTestTasks() {
    doLast {
        print "Test tasks size: ${project.tasks.withType(Test).size()}\n"

        project.tasks.withType(Test) { Test test ->
            print test.name.capitalize() + ' '
            print test?.testClassesDirs + ' '
            println()
        }
    }
}

with such result:

Test tasks size: 2

TestDebugUnitTest [..\lib\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debugUnitTest\R.jar, ..\lib\build\intermediates\javac\debugUnitTest\classes,  ]
	
TestReleaseUnitTest [..\lib\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\releaseUnitTest\R.jar, ..\lib\build\intermediates\javac\releaseUnitTest\classes,  ]

Stack trace: A problem occurred configuring project ':lib'.

Failed to notify project evaluation listener. Could not create task ':lib:testDebugUnitTest'. > Could not create task ':lib:cloverInstrumentCodeForTestDebugUnitTest'. > Could not create task of type 'CloverInstrumentationTask'. > java.lang.NullPointerException (no error message) Could not create task ':lib:cloverInstrumentCodeForCustomTest'. > Could not create task of type 'CloverInstrumentationTask'. > java.lang.NullPointerException (no error message)

Caused by: java.lang.RuntimeException: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':lib:testDebugUnitTest'.

Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':lib:testDebugUnitTest'.

Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':lib:cloverInstrumentCodeForTestDebugUnitTest'. at com.bmuschko.gradle.clover.CloverPlugin.configureActionsForTask(CloverPlugin.groovy:114)

at com.bmuschko.gradle.clover.CloverPlugin$_configureActions_closure2.doCall(CloverPlugin.groovy:92)

Caused by: org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'CloverInstrumentationTask'

Caused by: java.lang.NullPointerException at com.bmuschko.gradle.clover.CloverInstrumentationTask.(CloverInstrumentationTask.groovy:39)

Eugene-Novikov avatar May 24 '22 11:05 Eugene-Novikov

Android plugin has caused issues with this plugin before. I have been unable to test and understand the issues. Something unusual with the way the Android tooling sets up the source sets or the tasks causes an unexpected null pointer exception.

I thought I had added some defensive logic to correct the NPE although I cannot recall when that was done.

Alex-Vol avatar Jul 03 '22 19:07 Alex-Vol

I think I remember a situation that was caused by the Android tools setting the testClassesDirs property of the test task to null which is an invalid value when it should be a collection reference. But I do not have time or a way to test as I am not an Android developer myself.

Alex-Vol avatar Jul 03 '22 19:07 Alex-Vol