I have a Gradle plugin in buildSrc/src/main/kotlin/foo.bar.kts where I am trying to modify tasks, but those modification are failing. If I remove task modification parts, the rest, namely setting up repositories, works just fine.
I think I am missing the syntax how to modify tasks in the module that imports this plugin.
buildSrc/src/main/kotlin/foo.bar.kts:
repositories {
mavenCentral()
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "11"
}
Using the plugin in my build.gradle.kts
plugins {
id("foo.bar")
}
The errors that ./gradlew clean build generates
> Task :buildSrc:compileKotlin FAILED
e: /some/path/buildSrc/src/main/kotlin/foo.bar.gradle.kts: (8, 7): Unresolved reference: test
e: /some/path/buildSrc/src/main/kotlin/foo.bar.gradle.kts: (9, 5): Unresolved reference: useJUnitPlatform
e: /some/path/buildSrc/src/main/kotlin/foo.bar.gradle.kts: (12, 16): Unresolved reference: KotlinCompile
e: /some/path/buildSrc/src/main/kotlin/foo.bar.gradle.kts: (12, 33): Type mismatch: inferred type is () -> Unit but Class<TypeVariable(S)!> was expected
e: /some/path/buildSrc/src/main/kotlin/foo.bar.gradle.kts: (13, 5): Unresolved reference: kotlinOptions
e: /some/path/code/buildSrc/src/main/kotlin/foo.bar.gradle.kts: (13, 19): Variable expected