Skip to main content

PublishData

PublishData is a Gradle plugin. It takes the version of your project from git and publishes every build to the repository it belongs in.

  • Tag v1.4.0 and the build is version 1.4.0, published as a release. You do not need a commit that bumps the version.
  • Push a branch and it becomes 1.5.0-SNAPSHOT, published to your snapshot repository. If branches should not overwrite each other, it becomes 1.5.0-feature-x-SNAPSHOT.
  • It works on GitHub Actions, GitLab CI, Bitbucket Pipelines, Jenkins and any other CI. A build on your own machine never produces a release by accident.
  • It can write build information (version, commit, branch, build time) into your artifact.
  • It sets up maven-publish for you and supports the configuration cache.

Two more plugins come with it: a settings plugin that configures every project of a build at once, and the plugin manifest for Minecraft plugins.

Requirements​

WhatVersion
Gradle8.5 or newer
JavaThe Java that runs Gradle: 17 or newer for 2.1.0, 21 or newer from 2.2.0 on

Quick start​

PublishData is hosted on the EldoNexus, not on the Gradle Plugin Portal. Add the EldoNexus to the plugin repositories in settings.gradle.kts:

pluginManagement {
repositories {
gradlePluginPortal()
maven("https://eldonexus.de/repository/maven-public/")
}
}

Apply the plugin in build.gradle.kts and tell it where releases and snapshots go:

plugins {
`java-library`
`maven-publish`
id("de.chojo.publishdata") version "2.1.0"
}

publishData {
channels {
release("https://repo.example.com/releases")
snapshot("https://repo.example.com/snapshots")
}
repository {
credentials {
username = System.getenv("REPO_USER")
password = System.getenv("REPO_PASSWORD")
}
}
}

Put the next version into gradle.properties:

version=1.5.0

Now run ./gradlew publishChannel in your CI on every push. Branch builds publish 1.5.0-SNAPSHOT to the snapshot repository. A tag v1.5.0 publishes 1.5.0 to the release repository.

Without channels, the plugin only sets the version and publishes nothing.

Where to go next​