# The Groovy Gradle Plugin

version 9.8.0-20260814002830+0000

The Groovy Gradle Plugin (plugin id: `groovy-gradle-plugin`) lets you author Gradle plugins as precompiled Groovy DSL script plugins — `.gradle` scripts placed in a plugin source set such as `buildSrc` or an included `build-logic` build. Each script is compiled into a binary Gradle plugin whose ID is derived from the script’s file name (and optional package).

For a step-by-step authoring guide — deriving plugin IDs, exposing extensions, and applying the resulting plugins — see Precompiled Script Plugins. The Kotlin DSL equivalent is the `kotlin-dsl` plugin.

## Usage

Apply the plugin in the build script of the project that hosts your script plugins (for example, `buildSrc` or `build-logic`):

buildSrc/build.gradle.kts

    plugins {
        `groovy-gradle-plugin`
    }

buildSrc/build.gradle

    plugins {
        id 'groovy-gradle-plugin'
    }

Applying the plugin also applies the Groovy (base) plugin to compile the scripts and the Java Gradle Plugin Development plugin to expose them as plugins.

Gradle discovers every `.gradle` file in the plugin source set and registers it as a plugin in the `gradlePlugin {}` extension automatically. A script named `code-quality.gradle` becomes the `code-quality` plugin, and a package declaration adds a prefix (for example, `my.code-quality`). See the plugin ID section for details.

## Project layout

`src/main/groovy`

  Precompiled Groovy DSL script plugins (`.gradle` files). This is the Groovy source directory of the plugin source set configured on the `gradlePlugin {}` extension (the `main` source set by default).

## Tasks

The plugin adds the following tasks, which are wired into the compilation and output of the plugin source set. You do not normally run them directly; they participate automatically when the source set is built.

`extractPluginRequests` (type `ExtractPluginRequestsTask`)

  Extracts the `plugins {}` block from each script plugin so that the plugins it requests can be applied.

`generatePluginAdapters` (type `GeneratePluginAdaptersTask`)

  Generates the Java adapter classes that expose each script as a binary Plugin implementation. The generated sources are added to the plugin source set’s Java sources.

`compileGroovyPlugins` (type `CompileGroovyScriptPluginsTask`)

  Compiles the Groovy script plugins into plugin classes and adds them to the plugin source set’s output.

## Notes

- A precompiled script plugin ID must not start with `org.gradle` and must not conflict with a core Gradle plugin.

- The file-name suffix determines how a script is interpreted: `.gradle` becomes a `Plugin<Project>`, `.settings.gradle` a `Plugin<Settings>`, and `*.init.gradle` a `Plugin<Gradle>`.