I am looking for a modern custom plugin example wh...
# kotlin-dsl
f
I am looking for a modern custom plugin example which uses Kotlin for the plugin and the *.gradle.kts files. I found https://github.com/gradle/kotlin-dsl-samples/blob/master/samples/README.md Those are a few years old. Are they still current? In particular I am looking at something like: • https://github.com/gradle/kotlin-dsl-samples/tree/master/samples/testkithttps://github.com/gradle/kotlin-dsl-samples/blob/master/samples/gradle-pluginhttps://github.com/gradle/kotlin-dsl-samples/tree/master/samples/precompiled-script-plugin
c
kotlin-dsl
includes (applies) the
java-gradle-plugin
, adding Kotlin-isms to the DSL. Use
kotlin-dsl
if your plugin wishes to use the Kotlin Gradle DSL; use
java-gradle-plugin
if your plugin is Java-based. Don’t use both (there’s no harm in doing so, its just redundant), and don’t use either if you are not developing a plugin.
f
I am trying to implement: https://docs.gradle.org/current/userguide/implementing_gradle_plugins.html Option 6: Kotlin / Kotlin DSL Binary plugin : an abstract class that implements the
apply(Project project)
method of the
Plugin<Project>
interface in Kotlin and/or Kotlin DSL. I am looking for a simple complete example. Are the samples from https://github.com/gradle/kotlin-dsl-samples/tree/master/samples/testkit modern?
c
the
GreetPlugin
looks to be modern/idomatic, though it isn’t an abstract class (it isn’t required to be, though that is a good practice).
f
Which
GreetPlugin
? there are at least two. One is written with *.kts one is part of https://github.com/gradle/kotlin-dsl-samples/tree/master/samples/testkit . Is there another one? There is also, https://github.com/gradle/greeting-plugin-example/tree/master/src/main/java/org/example/greeting but it is written in Java. Then there is https://github.com/gradle/kotlin-dsl-samples/blob/master/samples/buildSrc-plugin/buildSrc/src/main/kotlin/GreetPlugin.kt with is a buildSrc example.