fix docker for tauri android build
This commit is contained in:
122
tauri_app/docker/ensure-tauri-androidx-offline.sh
Normal file
122
tauri_app/docker/ensure-tauri-androidx-offline.sh
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env bash
|
||||
# Download AndroidX artifacts required by Tauri offline APK builds but missed by Gradle export
|
||||
# (metadata POMs, version aliases, legacy lifecycle lines).
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
OFFLINE="${ROOT}/docker/offline-maven"
|
||||
|
||||
if [ ! -d "${OFFLINE}" ]; then
|
||||
echo "Offline Maven dir not found: ${OFFLINE}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAVEN_BASES=(
|
||||
"https://dl.google.com/dl/android/maven2"
|
||||
"https://dl.google.com/android/maven2"
|
||||
"https://maven.google.com"
|
||||
)
|
||||
|
||||
# group:artifact:version — from Tauri universalReleaseRuntimeClasspath resolution.
|
||||
REQUIRED=(
|
||||
"androidx.annotation:annotation:1.9.1"
|
||||
"androidx.annotation:annotation-jvm:1.9.1"
|
||||
"androidx.emoji2:emoji2:1.2.0"
|
||||
"androidx.emoji2:emoji2-views-helper:1.2.0"
|
||||
"androidx.emoji2:emoji2:1.3.0"
|
||||
"androidx.emoji2:emoji2-views-helper:1.3.0"
|
||||
"androidx.lifecycle:lifecycle-runtime:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-runtime-android:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-viewmodel:2.6.1"
|
||||
"androidx.lifecycle:lifecycle-viewmodel:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-viewmodel-android:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
|
||||
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
|
||||
"androidx.lifecycle:lifecycle-runtime-ktx:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-runtime-ktx-android:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-common:2.6.1"
|
||||
"androidx.lifecycle:lifecycle-common:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-common-jvm:2.6.1"
|
||||
"androidx.lifecycle:lifecycle-common-jvm:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1"
|
||||
"androidx.lifecycle:lifecycle-viewmodel-savedstate:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-viewmodel-savedstate-android:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-livedata-core:2.5.1"
|
||||
"androidx.lifecycle:lifecycle-livedata-core:2.10.0"
|
||||
"androidx.lifecycle:lifecycle-livedata:2.0.0"
|
||||
"androidx.lifecycle:lifecycle-livedata:2.10.0"
|
||||
"androidx.savedstate:savedstate:1.2.1"
|
||||
"androidx.savedstate:savedstate:1.4.0"
|
||||
"androidx.savedstate:savedstate-android:1.2.1"
|
||||
"androidx.savedstate:savedstate-android:1.4.0"
|
||||
"androidx.savedstate:savedstate-ktx:1.2.1"
|
||||
"androidx.savedstate:savedstate-ktx:1.4.0"
|
||||
)
|
||||
|
||||
download_file() {
|
||||
local url="$1"
|
||||
local dest="$2"
|
||||
mkdir -p "$(dirname "${dest}")"
|
||||
curl -fsSL --connect-timeout 20 --max-time 120 "${url}" -o "${dest}"
|
||||
}
|
||||
|
||||
try_download_ext() {
|
||||
local group="$1"
|
||||
local artifact="$2"
|
||||
local version="$3"
|
||||
local ext="$4"
|
||||
local group_path="${group//./\/}"
|
||||
local dest="${OFFLINE}/${group_path}/${artifact}/${version}/${artifact}-${version}.${ext}"
|
||||
|
||||
if [ -f "${dest}" ] && [ -s "${dest}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
for base in "${MAVEN_BASES[@]}"; do
|
||||
local url="${base}/${group_path}/${artifact}/${version}/${artifact}-${version}.${ext}"
|
||||
if download_file "${url}" "${dest}" 2>/dev/null && [ -s "${dest}" ]; then
|
||||
echo " + ${group}:${artifact}:${version}.${ext}"
|
||||
return 0
|
||||
fi
|
||||
rm -f "${dest}"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ensure_coordinate() {
|
||||
local spec="$1"
|
||||
IFS=':' read -r group artifact version <<< "${spec}"
|
||||
local got=0
|
||||
for ext in pom module aar jar; do
|
||||
if try_download_ext "${group}" "${artifact}" "${version}" "${ext}"; then
|
||||
got=1
|
||||
fi
|
||||
done
|
||||
if [ "${got}" -eq 0 ]; then
|
||||
echo "WARN: nothing downloaded for ${spec}" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
echo "==> Ensuring Tauri-required AndroidX artifacts in ${OFFLINE}"
|
||||
for spec in "${REQUIRED[@]}"; do
|
||||
echo "-- ${spec}"
|
||||
ensure_coordinate "${spec}"
|
||||
done
|
||||
|
||||
required_files=(
|
||||
"${OFFLINE}/androidx/annotation/annotation/1.9.1/annotation-1.9.1.pom"
|
||||
"${OFFLINE}/androidx/lifecycle/lifecycle-runtime/2.10.0/lifecycle-runtime-2.10.0.pom"
|
||||
"${OFFLINE}/androidx/emoji2/emoji2-views-helper/1.2.0/emoji2-views-helper-1.2.0.pom"
|
||||
"${OFFLINE}/androidx/savedstate/savedstate/1.2.1/savedstate-1.2.1.pom"
|
||||
"${OFFLINE}/androidx/lifecycle/lifecycle-viewmodel/2.6.1/lifecycle-viewmodel-2.6.1.pom"
|
||||
)
|
||||
|
||||
for file in "${required_files[@]}"; do
|
||||
if [ ! -f "${file}" ]; then
|
||||
echo "Missing required file after ensure: ${file}" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "==> Tauri AndroidX ensure complete"
|
||||
Reference in New Issue
Block a user