UniPub (Unified Publishing) is a Gradle plugin designed to make publishing to Maven repositories safer and cleaner.
Instead of wiring credentials directly into your build.gradle.kts, UniPub keeps sensitive data separate and
injects it automatically at publish time.
Think of it as a secrets bridge on top of existing publishing plugins like Gradle’s built-in maven-publish
or vanniktech’s maven publish plugin.
- Secure Credential Handling: Reads repository credentials and signing keys from a non-version-controlled YAML file.
- Environment Variable Support: Supports
ENV(VARIABLE_NAME)syntax to load secrets directly from your environment. - Profile-based Configuration: Use multiple profiles (e.g.,
main,staging,ci) without touching build logic. - Automatic Injection: Intercepts
publishtasks (maven-publish, vanniktech, etc.) and injects the correct credentials. - GPG Signing Support: Optionally loads GPG keys in-memory for CI/CD pipelines (
useInMemoryPgpKey()). - Tasks for Setup: Generate ready-to-edit
.unipub.ymltemplates in your project or home directory, with.gitignoresafety built in.
plugins {
id("dev.mtctx.unipub") version "LATEST_VERSION"
}👉 Check the Gradle Plugin Portal for the latest version.
Generate a starter template:
./gradlew generateUniPubFileInProjectDir # creates ./unipub.yml (gitignored)
./gradlew generateUniPubFileInHomeDir # creates ~/.unipub.ymlExample unipub.yml:
profiles:
- name: "main"
username: "ENV(OSSRH_USERNAME)"
password: "ENV(OSSRH_PASSWORD)"Use your publishing plugin of choice (maven-publish, vanniktech, etc.).
UniPub will inject the credentials automatically when you run publish.
Minimal example:
plugins {
`maven-publish`
id("dev.mtctx.unipub") version "LATEST_VERSION"
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
repositories {
maven {
name = "mavenCentral"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
}
}
}
unipub {
profileName.set("main") // optional, defaults to "primary"
}- UniPub loads your secrets from
unipub.yml(project-local or global). - On
PublishToMavenRepositorytasks, UniPub checks the target repository. - If credentials are missing, UniPub injects
username/passwordfrom your profile.
Your build scripts stay clean — no more hardcoded secrets.
- API Reference: API Docs
- Latest Version: Gradle Plugin Portal
This project is licensed under GNU GPL v3.0.