diff --git a/buildSrc/src/main/kotlin/Common.kt b/buildSrc/src/main/kotlin/Common.kt index 7ed97c9295..fac034734d 100644 --- a/buildSrc/src/main/kotlin/Common.kt +++ b/buildSrc/src/main/kotlin/Common.kt @@ -32,39 +32,8 @@ object Common { @JvmStatic fun getBuildVersionCode(project: Project): Int { - // .git/HEAD描述当前目录所指向的分支信息,内容示例:"ref: refs/heads/master\n" - val headFile = File(project.rootProject.projectDir, ".git" + File.separator + "HEAD") - if (headFile.exists()) { - var commitHash: String - val strings = headFile.readText(Charsets.UTF_8).split(" ") - if (strings.size > 1) { - val refFilePath = ".git" + File.separator + strings[1]; - // 根据HEAD读取当前指向的hash值,路径示例为:".git/refs/heads/master" - val refFile = File(project.rootProject.projectDir, refFilePath.replace("\n", "").replace("\r", "")); - // 索引文件内容为hash值+"\n", - commitHash = refFile.readText(Charsets.UTF_8) - } else { - commitHash = strings[0] - } - commitHash = commitHash.trim() - val repo = FileRepository(project.rootProject.file(".git")) - val refId = repo.resolve(commitHash) - val iterator = Git(repo).log().add(refId).call().iterator() - var commitCount = 0 - while (iterator.hasNext()) { - commitCount++ - iterator.next() - } - repo.close() - println("commit Count: $commitCount") - val targetVersionCode = commitCount + 1645300000 - println("target versionCode: $targetVersionCode") - return targetVersionCode - } else { - println("WARN: .git/HEAD does NOT exist") - return 1 - } + val currentTimestamp = (System.currentTimeMillis() / 1000L).toInt() + println("currentVersionCode: $currentTimestamp") + return currentTimestamp } - - }