[フレーム]
Last Updated: February 25, 2016
·
7.942K
· Lorin Hochstein

Accessing git branch name in gradle

Here's an example build.gradle snippet that uses [gradle-git][1] to retrive the branch name, which is used to set the version.

buildscript {
 repositories {
 mavenCentral()
 }
 dependencies {
 classpath 'org.ajoberstar:gradle-git:1.1.0'
 }
}

apply plugin: 'java'
import org.ajoberstar.grgit.*
ext.repo = Grgit.open(project.file('.'))

version = "1.1-${ext.repo.branch.current.name}"

[1]: https://github.com/ajoberstar/gradle-git

AltStyle によって変換されたページ (->オリジナル) /