#!/usr/bin/env bash # Run the pinned Gradle on this project: fetched once into a cache directory and checked against # its published SHA-256 before it is unpacked, so no wrapper binary lives in the repository. # # scripts/gradle.sh :core:test the JVM tests (build the host library first) # scripts/gradle.sh :sink:assembleRelease the AAR (build the Android libraries first) # scripts/gradle.sh -Pwai.sink.jvmOnly=true :core:test on a host with no Android SDK # # WAI_SINK_GRADLE_DISTS: where the distribution is kept (default /wai-sink-dists). # The daemon is off unless WAI_SINK_GRADLE_DAEMON=1: the hosts these run on are shared. set -euo pipefail . "$(dirname "${BASH_SOURCE[0]}")/env.sh" [ -n "${JAVA_HOME:-}" ] || die "no JDK 17 found: set JAVA_HOME" V=$WAI_SINK_GRADLE_VERSION D="${WAI_SINK_GRADLE_DISTS:-${GRADLE_USER_HOME:-$HOME/.gradle}/wai-sink-dists}" G="$D/gradle-$V/bin/gradle" if [ ! -x "$G" ]; then mkdir -p "$D" T="$(mktemp -d "$D/fetch.XXXXXX")" trap 'rm -rf "$T"' EXIT curl -fsSL --retry 3 -o "$T/g.zip" "https://services.gradle.org/distributions/gradle-$V-bin.zip" got="$(sha256_of "$T/g.zip")" [ "$got" = "$WAI_SINK_GRADLE_SHA256" ] || die "gradle-$V-bin.zip has SHA-256 $got, not the pinned $WAI_SINK_GRADLE_SHA256" (cd "$T" && unzip -q g.zip) [ -x "$G" ] || mv "$T/gradle-$V" "$D/gradle-$V" fi daemon=--no-daemon [ "${WAI_SINK_GRADLE_DAEMON:-0}" = 1 ] && daemon=--daemon exec "$G" -p "$WAI_SINK_DIR" $daemon --console=plain "$@"