Skip to content

Usage

Installation

Add the plugin to your plugins block in module build.gradle.kts or in the root build.gradle.kts:

plugins {
    id("io.github.kansalmohit19.git-version") version "X.Y.Z"
}

Usage

1. Android example

android {
    defaultConfig {
        versionCode = gitVersion.code.get()
        versionName = gitVersion.name.get()
    }
}

2. Custom task example

tasks.register("generateGitVersion") {
    doLast {
        println("App Version → Code=${gitVersion.code.get()}, Name=${gitVersion.name.get()}")
    }
}

Example Output

./gradlew printGitVersion

GitVersion: code=38, name=3.8