# Binary Plugin Publishing

version 9.5.0-20260327013305+0000

Once your plugin is complete and tested, you may want to publish it so it can be reused across multiple builds or even shared with others.

There are a number of plugins available to publish your plugin. For now, we will use the core `maven-publish` plugin. The `maven-publish` plugin lets you publish artifacts (like JARs, libraries, or plugins) to a Maven repository.

## Apply the Maven Publish Plugin

In your `plugin/build.gradle(.kts)`, apply the `maven-publish` plugin:

    plugins {
      `java-gradle-plugin`
      `maven-publish`
    }

A lot of the information needed to publish the plugin - `group`, `version`, and `id` - is already in your build file:

plugin/build.gradle.kts

    group = "org.example"   (3)
    version = "1.0.0"
    gradlePlugin {  (3)
        plugins {
            create("filesizediff") {
                id = "org.example.filesizediff"
                implementationClass = "org.example.FileSizeDiffPlugin"
            }
        }
    }

plugin/build.gradle

    group = "org.example"   (3)
    version = "1.0.0"
    gradlePlugin {  (3)
        plugins {
            filesizediff {
                id = 'org.example.filesizediff'
                implementationClass = 'org.example.FileSizeDiffPlugin'
            }
        }
    }

`group = "org.example"` sets the group ID of the plugin.

`version = "1.0.0"` sets the version of the plugin artifact.

The `gradlePlugin {}` block is part of the `java-gradle-plugin` and declares a binary plugin. It registers the full plugin name `org.example.filesizediff`, backed by a class called `FileDiffPlugin`. This is the class that implements `Plugin<Project>` and defines what happens when the plugin is applied.

## Configure the Publishing Block

In your `plugin/build.gradle(.kts)` file, configure the plugin for publication by defining where to publish it. Inside the `publishing {}` block, you specify the repository to publish to:

    publishing {
        repositories {
            maven {
                url = uri("${layout.projectDirectory}/publish")
            }
        }
    }

## Publish the Plugin

To publish, run:

    $ ./gradlew publish

This will generate and install the plugin JAR and associated metadata (like `pom.xml`) into the specified Maven repository.

Ready to build something? Start with the Advanced Tutorial.

Next Step: Start the Tutorial >>