Precompiled Script Plugin Sample
You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship. |
This sample shows how to use a precompiled script plugin to organize build logic in your build. A precompiled script plugin is a Kotlin script compiled as part of a regular Kotlin source-set and distributed in any way a Gradle plugin can be distributed. Precompiled script plugins can only be written in Kotlin at the moment, but these plugins can be applied in projects that use either the Groovy or Kotlin DSL.
The Gradle plugin id by which the precompiled script can be referenced is derived from its name and optional package declaration.
plugins {
id("org.gradle.sample.my-plugin")
}
plugins {
id("org.gradle.sample.my-plugin")
}
The sample is comprised of two builds:
-
The
plugin
build that contains the Gradle plugin implemented as a precompiled script. -
The root build is a user of the plugin above.
Running the task added by the precompiled script plugin:
$ ./gradlew greet > Task :greet Hello, World! BUILD SUCCESSFUL 1 actionable task: 1 executed