I'm trying to convert some task configuration in my Gradle plugin from Groovy to Kotlin. All of the examples I've found are about normal build scripts, and that approach doesn't seem to directly translate to plugin usage. My attempt below:
class JavaConventionsPlugin : Plugin<Project> {
// ...
fun configureBasicJavaOptions(project: Project) {
project.tasks.withType<JavaCompile> {
options.encoding = "cp1252"
options.warning = false
}
}
}
produces these errors:
- Type mismatch: inferred type is () -> Unit but Class<TypeVariable(S)!>! was expected
- Unresolved reference: options
- Variable expected
What the right way to do this?