# Precompiled Script Plugin Sample

version 6.2.1

- Groovy DSL

- Kotlin DSL

| 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.

build.gradle

    plugins {
        id("org.gradle.sample.my-plugin")
    }

build.gradle.kts

    plugins {
        id("org.gradle.sample.my-plugin")
    }

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:

    $ ./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