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}/kotlin_dsl.html#kotdsl:precompiled_plugins[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.

====
include::sample[dir="samples/precompiled-script-plugin/groovy",files="build.gradle[]"]
include::sample[dir="samples/precompiled-script-plugin/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:
====
[.testable-sample,dir="groovy"]
=====
[.sample-command]
----
$ ./gradlew greet

> Task :plugin:extractPrecompiledScriptPluginPlugins
> Task :plugin:generateExternalPluginSpecBuilders
> Task :plugin:compilePluginsBlocks
> Task :plugin:generatePrecompiledScriptPluginAccessors
> Task :plugin:configurePrecompiledScriptDependenciesResolver
> Task :plugin:generateScriptPluginAdapters
> Task :plugin:compileKotlin
> Task :plugin:compileJava NO-SOURCE
> Task :plugin:pluginDescriptors
> Task :plugin:processResources
> Task :plugin:classes
> Task :plugin:inspectClassesForKotlinIC
> Task :plugin:jar

> Task :greet
Hello, World!

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed

----
=====
====