# Gradle Plugin Sample

version 7.6.6-20260801035835+0000

- 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 build a Gradle plugin in the Java language.

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'
            }
        }
    }

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"
        }
    }

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

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