Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Eugene-Novikov opened this issue May 24, 2022 · 2 comments

Comments

@Eugene-Novikov
Copy link

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)

@Alex-Vol
Copy link
Collaborator

Alex-Vol commented Jul 3, 2022

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
Copy link
Collaborator

Alex-Vol commented Jul 3, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants