Home

Gradle plugin to auto-increments the patch version on each call to the publish task by looking up the most recent version published in the publishing maven repository and adds it by one.

Tested to work in the following scenarios:

  1. Single root project publication

  2. Single and multiple subprojects publication

  3. BOM references via api(platform(project(":bom"))) and java-platform plugin

  4. Manual versioning, prevents the task from publishing if the version isn’t different from the one in maven

semantic version plugin

Change Log

  • 0.2.x compatible with Java 11

    • 0.2.0 set compatability to Java 11, bump dependency versions, and upgrade gradle to 8.1

  • 0.1.x compatible with Java 8

    • 0.1.5 fix bug when the plugin wasn’t applying correct to root projects without jars

    • 0.1.4 fix bug when major or minor version was bump was computed incorrectly

    • 0.1.3 adds manual mode flag to skip publishing when artifact already exists

    • 0.1.2 fix bug with version finder

    • 0.1.1 unknown

    • 0.1.0 unknown

Import

plugins {
    `maven-publish`
    id("dev.poolside.gradle.semantic-version") version "0.2.0"
}
$ ./gradlw publish
[...]
> Task :semanticVersion
Resolved published version of 'dev.poolside.test:my-library:0.1.4' to '0.1.5'
[...]

Usage

Auto mode

Basic full example, but it can also be used for subprojects and bom subprojects. However, make sure the publication version number is in the format of \.[\d].

plugins {
    java
    `maven-publish`
    id("dev.poolside.gradle.semantic-version") version "0.2.0"
}
repositories {
    mavenCentral()
}

group = "dev.poolside.test"
version = "0.1"

publishing {
    publications {
        create("mavenJava") {
            artifactId = "my-library"
            from(components["java"])
        }
    }
}

Manual mode

If there’s a scenario in which you want to manually increment the semantic version. Therefore, the plugin will disable publishing if the version already exists in the repository.

semanticVersion {
    manual = true
}