Files
IdP/tauri_app/docker/prefetch-android-agp.sh
lendry 65abf17421 fix
2026-06-26 20:15:13 +03:00

49 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Pre-download Android Gradle Plugin into a local Maven repo inside the image.
set -euo pipefail
AGP_VERSION="${ANDROID_GRADLE_PLUGIN_VERSION:-8.11.0}"
LOCAL_REPO="${ANDROID_AGP_LOCAL_REPO:-/opt/android-agp-maven}"
try_download() {
local base_url="$1"
local dest_dir="${LOCAL_REPO}/com/android/tools/build/gradle/${AGP_VERSION}"
mkdir -p "${dest_dir}"
if curl -fsSL --connect-timeout 20 --max-time 120 \
"${base_url}/com/android/tools/build/gradle/${AGP_VERSION}/gradle-${AGP_VERSION}.pom" \
-o "${dest_dir}/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_dir}/gradle-${AGP_VERSION}.jar"
echo "${base_url}"
return 0
fi
return 1
}
echo "==> Prefetch Android Gradle Plugin ${AGP_VERSION}"
MIRROR=""
for base in \
"https://maven.google.com" \
"https://dl.google.com/android/maven2" \
"https://dl.google.com/dl/android/maven2"; do
if MIRROR="$(try_download "${base}")"; then
echo "==> AGP ${AGP_VERSION} cached from ${MIRROR}"
break
fi
done
if [ -z "${MIRROR}" ]; then
echo "Не удалось скачать Android Gradle Plugin ${AGP_VERSION} ни из одного зеркала Google Maven" >&2
exit 1
fi
cat > "${LOCAL_REPO}/README.txt" <<EOF
Local cache for com.android.tools.build:gradle:${AGP_VERSION}
Source: ${MIRROR}
EOF
echo "==> Local AGP repo: ${LOCAL_REPO}"