# Gradle Plugin Sample

version 9.1.0-20250822022355+0000

- Groovy DSL

- Kotlin DSL

| You can open this sample in an IDE that supports Gradle.

This sample shows how to build a Gradle plugin in the Java language.

greeting-plugin/build.gradle.kts

    plugins {
        // Apply the Java Gradle plugin development plugin to add support for developing Gradle plugins
        `java-gradle-plugin`
    }

    repositories {
        // Use Maven Central for resolving dependencies
        mavenCentral()
    }

    dependencies {
        // Use JUnit test framework for unit tests
        testImplementation("junit:junit:4.13")
    }

    gradlePlugin {
        // Define the plugin
        val greeting by plugins.creating {
            id = "com.example.plugin.greeting"
            implementationClass = "com.example.plugin.GreetingPlugin"
        }
    }

greeting-plugin/build.gradle

    plugins {
        // Apply the Java Gradle plugin development plugin to add support for developing Gradle plugins
        id 'java-gradle-plugin'
    }

    repositories {
        // Use Maven Central for resolving dependencies.
        // You can declare any Maven/Ivy/file repository here.
        mavenCentral()
    }

    dependencies {
        // Use JUnit test framework for unit tests
        testImplementation 'junit:junit:4.13'
    }

    gradlePlugin {
        // Define the plugin
        plugins {
            greeting {
                id = 'com.example.plugin.greeting'
                implementationClass = 'com.example.plugin.GreetingPlugin'
            }
        }
    }

For a more guided tour with plugin development, see the guides for plugin development.

You can also generate this project locally using `gradle init`.