Add full offline Android Gradle Plugin dependency cache

This commit is contained in:
lendry
2026-06-26 20:55:41 +03:00
parent 8805ec327f
commit 07df6eacf1
266 changed files with 14499 additions and 26 deletions

View File

@@ -1,35 +1,34 @@
#!/usr/bin/env bash
# Download Android Gradle Plugin into tauri_app/docker/offline-maven for offline Docker builds.
# Download Android Gradle Plugin and all transitive deps into offline-maven.
# Run once on a machine with internet access, then commit tauri_app/docker/offline-maven/.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
AGP_VERSION="${ANDROID_GRADLE_PLUGIN_VERSION:-8.11.0}"
DEST="${ROOT}/docker/offline-maven/com/android/tools/build/gradle/${AGP_VERSION}"
RESOLVER="${ROOT}/docker/agp-resolver"
OFFLINE="${ROOT}/docker/offline-maven"
mkdir -p "${DEST}"
if [ ! -x "${RESOLVER}/gradlew" ]; then
echo "Gradle wrapper not found in ${RESOLVER}" >&2
exit 1
fi
try_download() {
local base_url="$1"
if curl -fsSL --connect-timeout 20 --max-time 120 \
"${base_url}/com/android/tools/build/gradle/${AGP_VERSION}/gradle-${AGP_VERSION}.pom" \
-o "${DEST}/gradle-${AGP_VERSION}.pom"; then
curl -fsSL --connect-timeout 20 --max-time 600 \
"${base_url}/com/android/tools/build/gradle/${AGP_VERSION}/gradle-${AGP_VERSION}.jar" \
-o "${DEST}/gradle-${AGP_VERSION}.jar"
echo "==> AGP ${AGP_VERSION} saved to ${DEST} (source: ${base_url})"
return 0
fi
return 1
}
echo "==> Resolving AGP ${AGP_VERSION} dependency tree into ${OFFLINE}"
cd "${RESOLVER}"
chmod +x ./gradlew
./gradlew exportOfflineMaven --no-daemon -PagpVersion="${AGP_VERSION}"
for base in \
"https://maven.google.com" \
"https://dl.google.com/android/maven2" \
"https://dl.google.com/dl/android/maven2"; do
if try_download "${base}"; then
exit 0
fi
done
if [ ! -f "${OFFLINE}/.agp-offline-complete" ]; then
echo "Offline export did not complete successfully" >&2
exit 1
fi
echo "Не удалось скачать AGP ${AGP_VERSION}. Проверьте доступ к Google Maven." >&2
exit 1
if [ ! -f "${OFFLINE}/com/android/tools/build/builder/${AGP_VERSION}/builder-${AGP_VERSION}.pom" ]; then
echo "Missing required AGP dependency builder:${AGP_VERSION} in offline cache" >&2
exit 1
fi
TOTAL_SIZE="$(du -sh "${OFFLINE}" | awk '{print $1}')"
MODULES="$(find "${OFFLINE}" -name '*.jar' | wc -l | tr -d ' ')"
echo "==> Offline AGP cache ready: ${MODULES} jar(s), total ${TOTAL_SIZE}"
echo "==> Commit tauri_app/docker/offline-maven/ and push to the server"