The Kotlin function below compiles fine when in build.gradle.kts
and can be used in that file.
The same function in a normal .kt
file, however, outputs a compile error for the line with the comment // ERROR HERE
.
Is it possible to fix this? If so, how?
// Imports only in .kt file, not in build.gradle.kts
import org.gradle.api.Task
import org.gradle.kotlin.dsl.getting
val Task.isTestCompile: Boolean
get() {
val testClasses by project.tasks.getting // ERROR HERE
return testClasses.taskDependencies.getDependencies(testClasses).contains(this)
}
The command-line gradlew error is:
Missing 'getValue(Nothing?, KProperty<*>)' method on delegate of type 'ExistingDomainObjectDelegate<out Task!>'
In IntelliJ 2019.3 Beta, the error is:
Type 'ExistingDomainObjectDelegate<out Task!>' has no method 'getValue(Nothing?, KProperty<*>)' and thus it cannot serve as a delegate