Publishing Plugins to the Gradle Plugin Portal
Publishing a plugin is the main way to make it available for others to use. One approach is to publish the plugin to a private repository, which is common when you want to restrict who can use it. But if you want the plugin to be available to anyone in the world, i.e. public, then you should publish it to the Gradle Plugin Portal, a centralized, searchable repository dedicated to Gradle plugins.
This section will show you how to use the Plugin Publishing Plugin to publish plugins to the Gradle Plugin Portal using a convenient DSL. Taking this approach eliminates a large number of configuration steps and provides a number of checks to validate that your plugin meets the criteria enforced by the Gradle Plugin Portal.
Start with an existing Gradle plugin project
You will need an existing plugin project for this tutorial. If you don’t have your own, you may use the Greeting plugin sample.
Don’t worry about cluttering up the Gradle Plugin Portal with a trivial example plugin: trying to publish this plugin will safely fail with a permission error.
Create an account on the Gradle Plugin Portal
If you have never published a plugin to the Gradle Plugin Portal before, you first need to create an account there. This consists of three steps:
-
Create an account
-
Create an API key
-
Add your API key to your Gradle configuration
Start by going to the registration page — which looks like the image below – and creating an account.

Follow the instructions on that page. Once you have logged in, you can get your API key via the "API Keys" tab of your profile page.

It is common practice to copy and paste the text into your $HOME/.gradle/gradle.properties file, but you can also place it in any other valid location.
All that the plugin requires is that gradle.publish.key
and gradle.publish.secret
are available as project properties when the appropriate Plugin Portal tasks are executed.
If you are concerned about placing your credentials in gradle.properties
, investigate use of
Seauc Credentials plugin or the
Gradle Credentials plugin.
Once you have the API key you can publish as many plugins as you like.
Add the Plugin Publishing Plugin to the project
Add the Plugin Publishing Plugin to the plugins
block.
plugins {
id 'java-gradle-plugin' (1)
id 'maven-publish' (2)
id 'com.gradle.plugin-publish' version '1.0.0-rc-1' (3)
}
plugins {
id("java-gradle-plugin") (1)
id("maven-publish") (2)
id("com.gradle.plugin-publish") version "1.0.0-rc-1" (3)
}
1 | Use the Java Gradle Plugin Development Plugin, which comes with the Gradle distribution, to author your Gradle plugin. |
2 | Use the Maven Publish Plugin to generate the published metadata for your plugin |
3 | The latest version of the Plugin Publishing Plugin can be found on the Gradle Plugin Portal. |
Configure the Plugin Publishing Plugin
Create a pluginBundle
block in build.gradle
and specify global information regarding your plugin.
This helps other people browsing the portal find more information about your plugin and learn how to contribute to its development.
pluginBundle {
website = '<substitute your project website>' (1)
vcsUrl = '<uri to project source repository>' (2)
tags = ['tags', 'for', 'your', 'plugins'] (3)
}
pluginBundle {
website = "<substitute your project website>" (1)
vcsUrl = "<uri to project source repository>" (2)
tags = listOf("tags", "for", "your", "plugins") (3)
}
1 | Set the website for your plugin’s project. |
2 | Provide the source repository URI so that others can find it if they want to contribute. |
3 | Set the tags to be used for all plugins unless overridden in the plugins block. |
Now specify the details of the plugin.
This is done in a plugins
block within the gradlePlugin
block.
The most important part is the id
property, as that both uniquely identifies it on the Gradle Plugin Portal and prevents namespace clashes between different
plugin authors.
If you would like to associate your plugin with a particular organization, you also set the ID based on that organization’s domain using the
reverse-domain pattern used for Java packages, for example org.example.greeting
. If the plugin doesn’t belong to any specific organization,
then the plugin ID should be associated with the author, for example by using the author’s GitHub ID in a reverse domain pattern, like io.github.johndoe
.
Remember that the plugin id and project group should match, i.e. have the same top level namespace.
You can use the below example ID for the Greeting Plugin project, but substitute the values for more appropriate ones if you’re working with your own plugin that you actually want published.
group = 'io.github.johndoe' (1)
version = '1.0' (2)
gradlePlugin {
plugins { (3)
greetingsPlugin { (4)
id = '<your plugin identifier>' (5)
displayName = '<short displayable name for plugin>' (6)
description = '<Good human-readable description of what your plugin is about>' (7)
implementationClass = '<your plugin class>'
}
}
}
group = "io.github.johndoe" (1)
version = "1.0" (2)
gradlePlugin {
plugins { (3)
create("greetingsPlugin") { (4)
id = "<your plugin identifier>" (5)
displayName = "<short displayable name for plugin>" (6)
description = "<Good human-readable description of what your plugin is about>" (7)
implementationClass = "<your plugin class>"
}
}
}
1 | Make sure your project has a group set which is used for the artifacts (jar and metadata) you publish in the repository of the Gradle Plugin Portal
and which is descriptive of the plugin author or the organization the plugin belongs too. |
2 | Set the version for this publication. You need to increase the version, if you already published the plugin before. |
3 | Each plugin in a bundle is specified in the plugins blocks. As you are only publishing a single plugin at this point there will only be
one entry, but should your project publish a bundle in the future you will list each of them in here. |
4 | The name for each plugin block does not affect the plugin configuration, but needs to be unique for each plugin provided. |
5 | Set the unique id of the plugin. |
6 | Set the plugin name in human-readable form. |
7 | Set a description that will be displayed on the portal. it provides useful information to people would mightwant to use your plugin. Please give careful thought to the value of this property. |
If you are publishing multiple plugins, please note that it’s possible to use custom tags and a custom version per plugin using the pluginBundle block.
Please refer to the reference documentation of the Plugin Publishing Plugin for an example.
|
Think about what would be the correct metadata for your plugin and fill in the template appropriately.
Here is an example of the pluginBundle
configuration that you can use for the Greeting Plugin example:
pluginBundle {
website = 'https://www.gradle.org/'
vcsUrl = 'https://github.com/gradle/greeting-plugin-example'
tags = ['example', 'template']
}
gradlePlugin {
plugins {
greetingsPlugin {
id = 'org.example.greeting'
displayName = 'Greeting Plugin'
description = 'Template for people to start their own plugin adventure'
implementationClass = 'org.example.greeting.GreetingPlugin'
}
}
}
pluginBundle {
website = "https://www.gradle.org/"
vcsUrl = "https://github.com/gradle/greeting-plugin-example"
tags = listOf("example", "template")
}
gradlePlugin {
plugins {
create("greetingsPlugin") {
id = "org.example.greeting"
displayName = "Greeting Plugin"
description = "Template for people to start their own plugin adventure"
implementationClass = "org.example.greeting.GreetingPlugin"
}
}
}
As a second example of plugin configuration, consider the GradleTest plugin which is already published to the Gradle Plugin Portal.
pluginBundle {
website = 'https://github.com/ysb33r/gradleTest'
vcsUrl = 'https://github.com/ysb33r/gradleTest.git'
tags = ['testing', 'integrationTesting', 'compatibility']
}
gradlePlugin {
plugins {
gradletestPlugin {
id = 'org.ysb33r.gradletest'
displayName = 'Plugin for compatibility testing of Gradle plugins'
description = 'A plugin that helps you test your plugin against a variety of Gradle versions'
implementationClass = 'org.ysb33r.gradle.gradletest.GradleTestPlugin'
}
}
}
pluginBundle {
website = "https://github.com/ysb33r/gradleTest"
vcsUrl = "https://github.com/ysb33r/gradleTest.git"
tags = listOf("testing", "integrationTesting", "compatibility")
}
gradlePlugin {
plugins {
create("gradletestPlugin") {
id = "org.ysb33r.gradletest"
displayName = "Plugin for compatibility testing of Gradle plugins"
description = "A plugin that helps you test your plugin against a variety of Gradle versions"
implementationClass = "org.ysb33r.gradle.gradletest.GradleTestPlugin"
}
}
}
If you browse the associated page on the Gradle Plugin Portal for the GradleTest plugin, you will see how the specified metadata is displayed.

Publish your plugin to a local repository
To check how the artifacts of your published plugin look, or to use it only locally or internal in your company, you can publish it to any maven repository, including a local folder.
For that, you only need to configure repositories for publishing.
Then you can run the publish
task to publish your plugin to all repositories you have defined (but not the Gradle Plugin Portal).
publishing {
repositories {
maven {
name = 'localPluginRepository'
url = '../local-plugin-repository'
}
}
}
publishing {
repositories {
maven {
name = "localPluginRepository"
url = uri("../local-plugin-repository")
}
}
}
To use the repository in another build, you have to add it to the repositories of the pluginManagement {}
block in your settings.gradle(.kts)
file.
Publish your plugin to the Plugin Portal
Publish the plugin by using the publishPlugin
task.
$ ./gradlew publishPlugins
If you have not configured your Gradle Plugin Portal key and secret values in your gradle.properties
file, you can specify them on the command-line
$ ./gradlew publishPlugins -Pgradle.publish.key=<key> -Pgradle.publish.secret=<secret>
If you attempt to publish the example Greeting Plugin with the ID used in this section, you will encounter a permission failure. That’s expected and ensures that the portal won’t be overrun with multiple experimental and duplicate greeting-type plugins. |
Consume the published plugin
If your plugin is successfully published, you’ll be able to find instructions for its use at a URL of the form https://plugins.gradle.org/plugin/<your-plugin-id>. For example, the Greeting Plugin example is already on the portal at https://plugins.gradle.org/plugin/org.example.greeting.