There still is some ceremony to use precompiled script plugins. Agreed that the project-with-buildSrc sample should be enhanced to demonstrate this. The precompiled-script-plugins do demonstrate their use but in a “binary plugin” context instead of for local build logic. We’ll look into that.
In the meantime here are some instructions for using precompiled script plugins in buildSrc:
#1 add to your buildSrc/build.gradle.kts:
plugins {
`java-gradle-plugin`
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
}
dependencies {
// the dependencies used by your precompiled script plugins
}
#2 create a precompiled script at buildSrc/src/main/kotlin/my-plugin.gradle.kts
plugins { // Can use the plugins block but dependencies must be declared, see above
java
id("some-other-plugin")
}
// Custom build logic
#3 in your build scripts, you can then apply the my-plugin plugin, e.g. in sub-project/build.gradle.kts:
plugins {
id("my-plugin")
}
All build scripts can see classes from plugin coming from buildSrc.
The gradle/kotlin-dsl build make use of those precompiled scripts: https://github.com/gradle/kotlin-dsl/tree/develop/buildSrc/src/main/kotlin/plugins
HTH