Hi,
I have some “boilerplate” configuration that I would like to push into a script plugin so that it can be reused. For example:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = '1.8'
}
}
However, Gradle 4.9 doesn’t recognise the KotlinCompile
class from within a script plugin, and I am forced to write something like this instead:
tasks.withType(AbstractCompile).all {
if (it.class.name.startsWith("org.jetbrains.kotlin.gradle.tasks.KotlinCompile")) {
kotlinOptions {
jvmTarget = '1.8'
}
}
}
This works, but is ugly. Is there a better way to do this please?
Obviously script plugins have no difficulty with built-in task classes such as JavaCompile
.