Split check in gradle to better warn about GIT / admin right issues

This commit is contained in:
Dominik Dzienia 2020-04-13 19:47:47 +02:00
parent a640095b86
commit 780fd1aeaa

View file

@ -82,6 +82,23 @@ def isMaster = { ->
return !version.contains('-') return !version.contains('-')
} }
def gitAvailable = { ->
StringBuilder stringBuilder = new StringBuilder()
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', '--version'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
return false // NoGitSystemAvailable
}
return !stringBuilder.toString().isEmpty()
}
def allCommited = { -> def allCommited = { ->
StringBuilder stringBuilder = new StringBuilder() StringBuilder stringBuilder = new StringBuilder()
try { try {
@ -393,9 +410,13 @@ preBuild.dependsOn copyLibs
printf('--------------\n') printf('--------------\n')
printf('isMaster: %s\n', isMaster().toString()) printf('isMaster: %s\n', isMaster().toString())
printf('gitAvailable: %s\n', gitAvailable().toString())
printf('allCommited: %s\n', allCommited().toString()) printf('allCommited: %s\n', allCommited().toString())
printf('--------------\n') printf('--------------\n')
if (isMaster() && !gitAvailable()) {
throw new GradleException('GIT system is not available. On Windows try to run Android Studio as an Administrator. Check if GIT is installed and Studio have permissions to use it')
}
if (isMaster() && !allCommited()) { if (isMaster() && !allCommited()) {
throw new GradleException('There are uncommitted changes or git system is not available. Clone sources again as described in wiki and do not allow gradle update') throw new GradleException('There are uncommitted changes. Clone sources again as described in wiki and do not allow gradle update')
} }