Now Kotlin DSL generate type-safe accessors for tasks and task type is used in the configuration lambda.
But if task type is internal, will be generated accessor with type Task instead of the public parent type
Accessor should be generated with a closest parent public type.
Imagine this hierarchy:
abstract class MyCustomTask : DefaultTask()
internal class MyCustomTaskImpl : MyCustomTask()
Should be generated this accessor:
val TaskContainer.`myCustomTask`: TaskProvider<MyCustomTask>
get() = named<MyCustomTask>("myCustomTask")
Will be generated this accessor
val TaskContainer.`myCustomTask`: TaskProvider<Task>
get() = named("myCustomTask")
Also, configuration lambda type will be Any instead of Task:
tasks.myCustomTask {
// this receiver has type Any, not Task, but it's probably some invoke function resolution problem
}
Currently, Kotlin Gradle plugin itself has this problem because provides new Worker-based tasks implementation which is internal, so this broke type-safe accessors.
See https://youtrack.jetbrains.com/issue/KT-31435
Fixed in https://github.com/gradle/gradle/pull/9981, will be in Gradle 5.6
Most helpful comment
Fixed in https://github.com/gradle/gradle/pull/9981, will be in Gradle 5.6