diff --git a/build.gradle b/build.gradle index bbd1b16e6d5d..ed0b7d3cc73b 100644 --- a/build.gradle +++ b/build.gradle @@ -107,6 +107,12 @@ class TaggedLogOutputStream extends org.apache.commons.exec.LogOutputStream { } ext.geckoBinariesOnlyIf = { task -> + // Never when Gradle was invoked within `mach build`. + if ('1' == System.env.GRADLE_INVOKED_WITHIN_MACH_BUILD) { + rootProject.logger.lifecycle("Skipping task ${task.path} because: within `mach build`") + return false + } + // Never for official builds. if (mozconfig.substs.MOZILLA_OFFICIAL) { rootProject.logger.lifecycle("Skipping task ${task.path} because: MOZILLA_OFFICIAL") diff --git a/mobile/android/gradle.py b/mobile/android/gradle.py index 2c48c9cf0877..fa15c2263f83 100644 --- a/mobile/android/gradle.py +++ b/mobile/android/gradle.py @@ -5,6 +5,7 @@ from __future__ import print_function import buildconfig +import os import subprocess import sys @@ -30,7 +31,11 @@ def android(verb, *args): verb, ] cmd.extend(args) - subprocess.check_call(cmd) + env = dict(os.environ) + # Confusingly, `MACH` is set only within `mach build`. + if env.get('MACH'): + env['GRADLE_INVOKED_WITHIN_MACH_BUILD'] = '1' + subprocess.check_call(cmd, env=env) return 0 finally: