Stop Gradle installing on every checkout's emulator at once
The adb wrapper can only aim a call that goes through it, and Gradle's Android tasks do not: installDebug, uninstallDebug and connectedAndroidTest ask the adb server for every attached device and act on all of them. One session ran installDebug with two emulators up and replaced the app on both, which Gradle reported as success and the other session read as its own build never landing. `emu check` answers the question the wrapper already answers for adb -- would a command that reaches every attached device reach a stranger's emulator from here -- and install.sh links a Gradle init script into ~/.gradle/init.d so every build on this machine asks it, including checkouts nobody has adopted it in. It refuses narrowly: a lone emulator, a physical phone and a caller who named a device are all fine. ANDROID_SERIAL naming another checkout's emulator is not, because that is what a serial exported into a long-lived shell decays into once an emulator restarts and another's takes the port.
This commit is contained in:
1 parent
1da445ae32
commit
69a22c54e7
4 files changed
+158
-2
No files matched your search
+14
@@ -40,6 +40,20 @@ fi
|
||||
ln -sfn "$here/share/ui-trace" "$sharedir/ui-trace"
|
||||
echo "install: $sharedir/ui-trace -> $here/share/ui-trace"
|
||||
|
||||
# Gradle never goes through the adb wrapper -- its device tasks reach every
|
||||
# attached device by themselves -- so the one place that can hold for a
|
||||
# checkout nobody has adopted this in is an init script, which Gradle applies
|
||||
# to every build on this machine.
|
||||
gradledir=${GRADLE_INIT_DIR:-$HOME/.gradle/init.d}
|
||||
mkdir -p "$gradledir"
|
||||
init="$gradledir/emulator-tools.gradle"
|
||||
if [ -e "$init" ] && [ ! -L "$init" ]; then
|
||||
echo "install: keeping the existing emulator-tools.gradle as emulator-tools.gradle.bak"
|
||||
mv "$init" "$init.bak"
|
||||
fi
|
||||
ln -sfn "$here/share/gradle-init/emulator-tools.gradle" "$init"
|
||||
echo "install: $init -> $here/share/gradle-init/emulator-tools.gradle"
|
||||
|
||||
case ":$PATH:" in
|
||||
*":$bindir:"*) ;;
|
||||
*) echo "install: note -- $bindir is not on PATH" ;;
|
||||
|
||||
Reference in new issue
Block a user