From 8877571963f77a05ba3fd39ba7744190c2713529 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 2 Sep 2026 14:08:14 +0000 Subject: [PATCH] chore: add Cloud Agent environment setup for Android build Adds .cursor/environment.json and an idempotent install script that provisions the Android SDK (cmdline-tools, platform android-37.0, build-tools 37.0.0), writes local.properties, and warms Gradle dependencies so ./gradlew build/test/detekt work out of the box. Co-authored-by: Somasundaram M --- .cursor/environment.json | 4 +++ .cursor/install.sh | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .cursor/environment.json create mode 100755 .cursor/install.sh diff --git a/.cursor/environment.json b/.cursor/environment.json new file mode 100644 index 0000000..188c34e --- /dev/null +++ b/.cursor/environment.json @@ -0,0 +1,4 @@ +{ + "name": "BaseMVVM-AndroidKt", + "install": "bash .cursor/install.sh" +} diff --git a/.cursor/install.sh b/.cursor/install.sh new file mode 100755 index 0000000..c9ee773 --- /dev/null +++ b/.cursor/install.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# +# Idempotent Cloud Agent bootstrap for the BaseMVVM-AndroidKt project. +# Ensures the Android SDK, local.properties, and Gradle dependencies are ready. +# Safe to run repeatedly and on top of a prebuilt snapshot. +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-/opt/android-sdk}" +CMDLINE_TOOLS_VERSION="11076708" +PLATFORM="platforms;android-37.0" +BUILD_TOOLS="build-tools;37.0.0" + +log() { printf '\n[install] %s\n' "$*"; } + +# --- 1. Ensure the Android command-line tools exist ------------------------- +if [ ! -x "${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" ]; then + log "Installing Android command-line tools into ${ANDROID_SDK_ROOT}" + sudo mkdir -p "${ANDROID_SDK_ROOT}/cmdline-tools" + sudo chown -R "$(id -u):$(id -g)" "${ANDROID_SDK_ROOT}" + tmp="$(mktemp -d)" + curl -fsSL -o "${tmp}/cmdline-tools.zip" \ + "https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_TOOLS_VERSION}_latest.zip" + unzip -q "${tmp}/cmdline-tools.zip" -d "${tmp}/extracted" + rm -rf "${ANDROID_SDK_ROOT}/cmdline-tools/latest" + mv "${tmp}/extracted/cmdline-tools" "${ANDROID_SDK_ROOT}/cmdline-tools/latest" + rm -rf "${tmp}" +else + log "Android command-line tools already present" +fi + +SDKMANAGER="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" + +# --- 2. Accept licenses and ensure required SDK packages -------------------- +log "Accepting SDK licenses" +yes | "${SDKMANAGER}" --sdk_root="${ANDROID_SDK_ROOT}" --licenses >/dev/null 2>&1 || true + +log "Ensuring platform-tools, ${PLATFORM}, ${BUILD_TOOLS}" +"${SDKMANAGER}" --sdk_root="${ANDROID_SDK_ROOT}" \ + "platform-tools" "${PLATFORM}" "${BUILD_TOOLS}" >/dev/null + +# --- 3. Point the Gradle build at the SDK ---------------------------------- +log "Writing ${REPO_ROOT}/local.properties" +printf 'sdk.dir=%s\n' "${ANDROID_SDK_ROOT}" > "${REPO_ROOT}/local.properties" + +# --- 4. Warm the Gradle dependency cache ----------------------------------- +log "Warming Gradle dependencies" +cd "${REPO_ROOT}" +chmod +x ./gradlew +export ANDROID_SDK_ROOT ANDROID_HOME="${ANDROID_SDK_ROOT}" +./gradlew --no-daemon help -q >/dev/null + +log "Environment ready. SDK at ${ANDROID_SDK_ROOT}"