Gradle 获取 Git Commit 数量做版本号

使用到的库

buildscript {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    dependencies {
        // ...
        classpath("org.eclipse.jgit:org.eclipse.jgit:5.0.2.201807311906-r")
    }
}
val git = org.eclipse.jgit.api.Git(FileRepositoryBuilder.create(rootProject.file(".git")))
val bigVersion = project.properties["plugin.version"]
version = "${bigVersion}.${git.log().call().toList().size}"