Gradle plugin

Publishing

Library modules publish to GitHub Packages under names that never collide across plugins.

Your modules

Each module in publishedModules is published by ./gradlew publish with:

SettingValueExample
RepositoryGitHubPackages, https://maven.pkg.github.com/{gitOrgName}/{gitRepository}https://maven.pkg.github.com/Example/example-plugin
CredentialsGITHUB_ACTOR and GITHUB_TOKEN environment variables
groupIdproject-groupio.github.example
artifactId{rootProject.name}-{module}example-plugin-api
versionproject-version1.0.0
POM <url>pomUrlhttps://github.com/Example/example-plugin
POM <developers>the developer* properties, when set

The artifactId is qualified with the project name because every plugin in a group has an api module: bare module names would make two plugins publish the same io.github.example:api, and a consumer could not depend on both.

The artifactId and POM are set on every Maven publication of the module, including one the module declares itself, so a module's own pom { name = ... } is kept.

In CI

In GitHub Actions the workflow token can publish to the repository's own packages:

.github/workflows/publish.yml
permissions:
  contents: read
  packages: write
steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-java@v4
    with:
      distribution: temurin
      java-version: 25
  - run: ./gradlew publish
    env:
      GITHUB_ACTOR: ${{ github.actor }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Consuming a published module

Another plugin compiles against a published module without shading it, because the plugin that owns it is installed on the server:

build.gradle
repositories {
    maven {
        url = uri('https://maven.pkg.github.com/Example/example-plugin')
        credentials {
            username = System.getenv('GITHUB_ACTOR')
            password = System.getenv('GITHUB_TOKEN')
        }
    }
}

dependencies {
    compileOnly 'io.github.example:example-plugin-api:1.0.0'
}

The plugin itself

WhereCoordinates
Gradle Plugin Portalplugins { id 'io.github.mcengine.build-logic' version '0.2.0' }
GitHub Packages, the jario.github.mcengine:gradle-plugin:0.2.0 at https://maven.pkg.github.com/MCEngine/gradle-plugin
GitHub Packages, the plugin markerio.github.mcengine.build-logic:io.github.mcengine.build-logic.gradle.plugin:0.2.0

The jar depends on com.gradleup.shadow:shadow-gradle-plugin:9.4.1, which is how Shadow reaches your build classpath.

← Configuration Migrating a build →