Skip to content

lovef/gradle-git-version-plugin

Repository files navigation

Build Status Download

Gradle Git Version Plugin

Set version based on git tags and create new git version tags.

Example:

// build.gradle

plugins {
    id 'se.lovef.git-version' version '0.3.2'
}

version gitVersion('1.0')

println "gitVersion: $gitVersion"

task printGitVersion {
    doLast {
        println "gitVersion: $gitVersion"
    }
}

printGitVersion.mustRunAfter tag
// build.gradle.kts

plugins {
    id("se.lovef.git-version") version "0.3.2"
}

version = gitVersion("1.0")

println("gitVersion: $gitVersion")

tasks.register("printGitVersion") {
    doLast {
        println("gitVersion: $gitVersion")
    }
    mustRunAfter(tasks["tag"])
}

Output:

$ ./gradlew tag printGitVersion

> Configure project :
gitVersion: { version: "1.0-SNAPSHOT", tag: null }

> Task :tag
Created tag v1.0.0

Commands:

    git tag --delete v1.0.0    # delete
    git push origin  v1.0.0    # push to origin

New version: 1.0.0

> Task :printGitVersion
gitVersion: { version: "1.0.0", tag: "v1.0.0" }

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 executed

An attribution

This project is in part inspired by Git-Version Gradle Plugin

About

Gradle plugin for creating version tags in git

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published