Git rev-list not working in Android Studio build.gradle

前端 未结 5 519
清歌不尽
清歌不尽 2020-12-20 01:36

I\'ve setup my Android Studio Project to work with Github. Here is my Manifext

apply plugin: \'com.android.application\'


def gitVersion() {
    def counter         


        
5条回答
  •  情歌与酒
    2020-12-20 02:21

    This method will help you get your revision number:

    int extractVersionCode() {
        def stdout = new ByteArrayOutputStream()
        exec {
            workingDir projectDir
            executable 'git'
            args 'rev-list', '--count', 'HEAD'
            standardOutput = stdout
        }
        return stdout.toString().trim().toInteger()
    }
    

    Usage:

    versionCode extractVersionCode()
    

提交回复
热议问题