Table of Contents
The Java Gradle plugin development plugin is currently incubating. Please be aware that the DSL and other configuration may change in later Gradle versions.
The Java Gradle Plugin development plugin can be used to assist in the development of Gradle plugins. It automatically applies
the Java plugin, adds the gradleApi()
dependency to the compile configuration
and performs validation of plugin metadata during jar
task execution.
The plugin also integrates with TestKit, a library that aids in writing and executing functional
tests for plugin code. It automatically adds the gradleTestKit()
dependency to the test compile configuration
and generates a plugin classpath manifest file consumed by a GradleRunner
instance if found. Please refer to
Section 43.2.1.2, “Automatic injection with the Java Gradle Plugin Development plugin” for more on its usage, configuration options and samples.
To use the Java Gradle Plugin Development plugin, include the following in your build script:
Example 40.1. Using the Java Gradle Plugin Development plugin
build.gradle
plugins {
id "java-gradle-plugin"
}
Applying the plugin automatically applies the Java plugin and adds the
gradleApi()
dependency to the compile configuration. It also decorates the jar
task with validations.
The following validations are performed:
implementation-class
property.implementation-class
property references a valid class file in the jar.Any failed validations will result in a warning message.
For each plugin you are developing, add an entry to the gradlePlugin {}
script block:
Example 40.2. Using the gradlePlugin {} block.
build.gradle
gradlePlugin { plugins { simplePlugin { id = "org.gradle.sample.simple-plugin" implementationClass = "org.gradle.sample.SimplePlugin" } } }
The gradlePlugin {}
block defines the plugins being built by the project including the id
and
implementationClass
of the plugin. From this data about the plugins being developed, Gradle
can automatically:
jar
file's META-INF
directory.