This episode covers plugin and extension development with Groovy: creating Gradle plugins and Groovy application plugins, packaging and publishing artifacts, reuse in the build ecosystem, and contributing to community plugins and reusable scripts.

Once you're proficient at writing scripts and DSLs, the next step is packaging that knowledge into a plugin that many people can reuse. Plugins are how Groovy distributes extensions in a structured way.
Episode 18 covers creating Gradle plugins, extensions for Groovy applications, packaging and publishing, and contributing to community plugins and reusable scripts.
build.gradle
settings.gradle
src/main/groovy/com/example/GreetingPlugin.groovy
src/main/resources/META-INF/gradle-plugins/com.example.greeting.propertiesThe properties file links the plugin name to the implementation class. This is the contract Gradle reads when the plugin is applied.
package com.example
import org.gradle.api.Plugin
import org.gradle.api.Project
class GreetingPlugin implements Plugin<Project> {
void apply(Project project) {
project.tasks.register("hello") {
doLast {
println "Halo dari ${project.name}"
}
}
}
}class GreetingPlugin implements Plugin<Project> is the basic contract of every Gradle plugin. project.tasks.register("hello") creates a new task that appears when the plugin is applied — now other projects just apply this plugin to get the hello task.
implementation-class=com.example.GreetingPluginimplementation-class=com.example.GreetingPlugin links the plugin name com.example.greeting to the implementation class. implementation-class=com.example.GreetingPlugin is the only content that properties file needs.
class NotifikasiExtension {
String kanal = "slack"
int retry = 3
}class NotifikasiExtension defines configuration options with default values. String kanal = "slack" provides an initial value so users who configure nothing still get sensible behavior.
project.extensions.create("notifikasi", NotifikasiExtension)
project.tasks.register("kirimNotifikasi") {
doLast {
def config = project.extensions.notifikasi
println "Mengirim ke ${config.kanal} dengan retry ${config.retry}"
}
}project.extensions.create("notifikasi", NotifikasiExtension) registers an extension that users can access. project.extensions.notifikasi reads the configuration from within the task, so user-set options take effect immediately.
gradle jarplugins {
id "java-gradle-plugin"
id "maven-publish"
}
publishing {
publications {
pluginMaven(MavenPublication) {
from components.java
}
}
}plugins { id "java-gradle-plugin" } adds Gradle plugin support, and id "maven-publish" adds publishing. pluginMaven(MavenPublication) defines the publication, which is then executed with gradle publishToMavenLocal.
plugins {
id "com.example.greeting" version "1.0.0"
}id "com.example.greeting" version "1.0.0" applies the plugin along with its version. id "com.example.greeting" version "1.0.0" is the same pattern as the well-known Gradle plugins you've been using.
def sambut(String nama) {
"Halo, ${nama}"
}Save it as lib/sambutan.groovy, then use it from the main script:
evaluate(new File("lib/sambutan.groovy"))
println sambut("Arman")evaluate(new File("lib/sambutan.groovy")) executes another script and makes its methods available. evaluate(new File("lib/sambutan.groovy")) is a simple way to share code between scripts before upgrading to a proper library.
Many Groovy plugins and scripts are open-source. To contribute:
good first issue.Public plugins require high standards:
Episode 18 taught you how to package Groovy code into shareable assets: Gradle plugins, extension APIs, packaging and publishing, reusable scripts, and contributions to the open-source ecosystem.
The key takeaways:
Plugin<Project>.maven-publish distributes the plugin as an artifact.plugins { id ... version } block.evaluate shares code between Groovy scripts.In episode 19 next, we'll discuss operational readiness and runbooks — preparing runbooks for deployment and incident response, operational metrics, logging and runtime observability, as well as upgrade paths and compatibility checks for Groovy and JVM versions.