Skip to content

Commit

Permalink
Use temp dirs in lockfile script
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-mullvad committed Jun 18, 2024
1 parent e19b1f3 commit 535a073
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion android/scripts/update-lockfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,31 @@ set -eu
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# Disable daemon since it causes problems with the temp dir cleanup
# regardless if stopped.
GRADLE_OPTS="-Dorg.gradle.daemon=false"
# We must provide a template for mktemp to work properly on macOS.
GRADLE_USER_HOME=$(mktemp -d -t gradle-home-XXX)
TEMP_GRADLE_PROJECT_CACHE_DIR=$(mktemp -d -t gradle-cache-XXX)
GRADLE_TASKS=("assemble" "compileDebugUnitTestKotlin" "assembleAndroidTest" "lint")

export GRADLE_OPTS
export GRADLE_USER_HOME

function cleanup {
echo "Cleaning up temp dirs..."
rm -rf -- "$GRADLE_USER_HOME" "$TEMP_GRADLE_PROJECT_CACHE_DIR"
}

trap cleanup EXIT

echo "### Updating dependency lockfile ###"
echo "Gradle home: $GRADLE_USER_HOME"
echo "Gradle cache: $TEMP_GRADLE_PROJECT_CACHE_DIR"
echo ""

echo "Removing old components..."
sed -i '/<components>/,/<\/components>/d' ../gradle/verification-metadata.xml

echo "Generating new components..."
../gradlew -q -p .. -M sha256 assemble compileDebugUnitTestKotlin assembleAndroidTest lint
../gradlew -q -p .. --project-cache-dir "$TEMP_GRADLE_PROJECT_CACHE_DIR" -M sha256 "${GRADLE_TASKS[@]}"

0 comments on commit 535a073

Please sign in to comment.