Files
Amethyst-Android/build.gradle
2025-08-23 22:49:23 +08:00

34 lines
1007 B
Groovy

import java.io.IOException
plugins{
id 'com.android.application' version '8.7.2' apply false
id 'com.android.library' version '8.7.2' apply false
}
String getGitHash(File project) {
def command = Runtime.getRuntime().exec("git rev-list -1 HEAD " + project + "/src")
def returnCode = command.waitFor()
if (returnCode != 0) {
throw new IOException("Command 'getGitHash()' exited with " + returnCode)
}
String gitCommitHash = command.inputStream.text.trim()
return gitCommitHash
}
Boolean gitUsed() {
def returnCode = Runtime.getRuntime().exec("git rev-parse --is-inside-work-tree").waitFor()
switch(returnCode){
case 127:
println("git not found");
return false;
break;
case 128:
println("not inside a git repository");
return false;
break;
case 0:
return true;
default:
throw new IOException("Command 'gitUsed()' exited with " + returnCode)
}
}