diff --git a/app/build.gradle b/app/build.gradle index ceddd5d6fe..b1cab7995c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -82,6 +82,23 @@ def isMaster = { -> 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 = { -> StringBuilder stringBuilder = new StringBuilder() try { @@ -393,9 +410,13 @@ preBuild.dependsOn copyLibs printf('--------------\n') printf('isMaster: %s\n', isMaster().toString()) +printf('gitAvailable: %s\n', gitAvailable().toString()) printf('allCommited: %s\n', allCommited().toString()) 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()) { - 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') }