Skip to content

rahulsom/waena

Repository files navigation

Waena

GitHub commits since latest release

Waena is a set of Gradle plugins for publishing JVM artifacts. It supports publishing to Maven Central and GitHub Packages. Waena is Hawaiian for central.

Setup

There are 2 plugins that make up this project.

Waena Root

Gradle Plugin Portal

This needs to be applied only to the root project.

plugins {
  id("com.github.rahulsom.waena.root").version("<VERSION>")
}

allprojects {
  group = "TODO"
}

contacts {
    validateEmails = true
    addPerson("todo@noreply.github.com") {
        moniker("To Do")
        roles("owner")
        github("https://github.com/todo")
    }
}

Waena Published

Gradle Plugin Portal

This needs to be applied to each module in the project that needs to be published.

plugins {
  id("com.github.rahulsom.waena.published").version("<VERSION>")
}

description = "TODO"

// Optional — customize license and publish targets
waena {
    license.set(WaenaExtension.License.Apache2)
    // Publish to Maven Central only (default)
    publishModes.set(setOf(WaenaExtension.PublishMode.Central))
    // Or publish to both Maven Central and GitHub Packages
    // publishModes.set(setOf(WaenaExtension.PublishMode.Central, WaenaExtension.PublishMode.GitHub))
}

Usage

Environment Variables

Maven Central

Set these 4 environment variables for publishing to Maven Central:

export ORG_GRADLE_PROJECT_sonatypeUsername=???
export ORG_GRADLE_PROJECT_sonatypePassword=???
export ORG_GRADLE_PROJECT_signingKey=???
export ORG_GRADLE_PROJECT_signingPassword=???

GitHub Packages

GitHub Packages uses the GITHUB_ACTOR and GITHUB_TOKEN environment variables, which are automatically provided in GitHub Actions. For local publishing, set them explicitly:

export GITHUB_ACTOR=<your-github-username>
export GITHUB_TOKEN=<a-personal-access-token-with-write:packages-scope>

Alternatively, you can set them as Gradle project properties:

export ORG_GRADLE_PROJECT_githubPackagesUsername=???
export ORG_GRADLE_PROJECT_githubPackagesPassword=???

GitHub Actions permissions

When publishing to GitHub Packages from a GitHub Actions workflow, the job needs packages: write:

jobs:
  build:
    permissions:
      packages: write

If you use a reusable workflow, the permission must be declared in that workflow’s jobs.<job>.permissions block — permissions in the calling workflow do not grant additional permissions to the reusable workflow.

Remote Publishing Setup

Waena does not configure remote Sonatype/JReleaser publishing in included/composite builds by default. For standalone builds, it configures remote publishing only when a publishing-related task is requested (snapshot, candidate, final, tasks containing publish, release, sonatype, or jreleaser). This keeps regular build/test runs and composite builds from eagerly creating remote publishing repositories.

You can override this behavior with a project property:

# Force-enable remote publishing setup
./gradlew -PwaenaConfigureRemotePublishing=true test

# Force-disable remote publishing setup
./gradlew -PwaenaConfigureRemotePublishing=false final

Publishing snapshots

./gradlew snapshot

Snapshots are published to Sonatype snapshots when Central is in publishModes. GitHub Packages does not receive snapshots — only candidates and finals are published there.

Publishing releases

git tag v1.2.3 # Any semver compatible version prefixed by `v`
./gradlew -Prelease.useLastTag=true build final --stacktrace

Implementation Details

Under the hood, this uses several other plugins and ties them all together such that you can release to maven central easily

About

Gradle plugins for publishing to Maven Central

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors