In gradle-script-kotlin, tasks.getByName with closure errors with Value is null


(kevin.stembridge.dev) #1

Gradle Version:
3.1
Operating System and JVM version:
Ubuntu 15.10, jdk1.8.0_101



apply {
    plugin<JavaPlugin>()
}

tasks.getByName("clean") {
    println(it.javaClass)
}

tasks.getByName("clean", closureOf<Delete> {

})
Caused by: java.lang.IllegalArgumentException: Value is null
        at org.gradle.internal.metaobject.BeanDynamicObject.<init>(BeanDynamicObject.java:89)
        at org.gradle.internal.metaobject.BeanDynamicObject.<init>(BeanDynamicObject.java:80)
        at org.gradle.api.internal.DynamicObjectUtil.asDynamicObject(DynamicObjectUtil.java:30)
        at org.gradle.internal.metaobject.ConfigureDelegate.<init>(ConfigureDelegate.java:35)
        at org.gradle.util.ConfigureUtil.configureSelf(ConfigureUtil.java:136)
        at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:519)
        at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:76)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:104)
        at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:237)
        at org.gradle.api.internal.tasks.DefaultTaskCollection.getByName(DefaultTaskCollection.java:31)
        at Broken_build_gradle.<init>(broken.build.gradle.kts:13)
        at org.gradle.script.lang.kotlin.provider.KotlinBuildScriptCompiler.executeScriptOf(KotlinBuildScriptCompiler.kt:196)
        at org.gradle.script.lang.kotlin.provider.KotlinBuildScriptCompiler.executeScriptWithContextClassLoader(KotlinBuildScriptCompiler.kt:190)
        at org.gradle.script.lang.kotlin.provider.KotlinBuildScriptCompiler.access$executeScriptWithContextClassLoader(KotlinBuildScriptCompiler.kt:46)
        at org.gradle.script.lang.kotlin.provider.KotlinBuildScriptCompiler$onePassScript$1.invoke(KotlinBuildScriptCompiler.kt:110)
        at org.gradle.script.lang.kotlin.provider.KotlinBuildScriptCompiler$onePassScript$1.invoke(KotlinBuildScriptCompiler.kt:46)
        at org.gradle.script.lang.kotlin.provider.KotlinScriptPlugin.apply(KotlinScriptPlugin.kt:38)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        ... 51 more


(kevin.stembridge.dev) #2

Looks like a known issue.

And a solution has been provided here: