Merge pull request #2568 from dlvoy/dagger3-nogitcheck

Split check in gradle to better warn about GIT / admin right issues
This commit is contained in:
Milos Kozak 2020-04-13 20:00:42 +02:00 committed by GitHub
commit b48f8f4243
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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')
} }