:samples-dir: /home/tcagent1/agent/work/ff6c2020506a5c2d/promote-projects/gradle/build/git-checkout/subprojects/docs/build/working/samples/install/precompiled-script-plugin
:gradle-version: 6.4-20200421152022+0000

= Precompiled Script Plugin Sample

[.download]
- link:zips/sample_precompiled_script_plugin-groovy-dsl.zip[icon:download[] Groovy DSL]
- link:zips/sample_precompiled_script_plugin-kotlin-dsl.zip[icon:download[] Kotlin DSL]

NOTE: You can open this sample inside an IDE using the https://www.jetbrains.com/help/idea/gradle.html#gradle_import_project_start[IntelliJ native importer] or https://projects.eclipse.org/projects/tools.buildship[Eclipse Buildship].

This sample shows how to use a link:{userManualPath}/custom_plugins.html#sec:precompiled_plugins[precompiled script plugin] to organize build logic in your build.
A precompiled script plugin is a Groovy or Kotlin script compiled as part of a regular Groovy or Kotlin source-set and distributed in any way a Gradle plugin can be distributed.
These plugins can be applied in projects that use either the Groovy or Kotlin DSL.

[.multi-language-text.lang-groovy]
The Gradle plugin id by which the precompiled script can be referenced is derived from the script name.

[.multi-language-text.lang-kotlin]
The Gradle plugin id by which the precompiled script can be referenced is derived from the script name
and optional package declaration.

====
include::sample[dir="groovy",files="build.gradle[]"]
include::sample[dir="kotlin",files="build.gradle.kts[]"]
====

The sample is comprised of two builds:

1. The `plugin` build that contains the Gradle plugin implemented as a precompiled script.
2. The root build is a user of the plugin above.

Running the task added by the precompiled script plugin:
[listing.terminal.sample-command]
----
$ ./gradlew greet

> Task :greet
Hello, World!

BUILD SUCCESSFUL
1 actionable task: 1 executed
----
