Modern Apps git

← Modern-Apps.git

build: hooks locate a Gradle-capable JDK themselves

Commit
29bb3c815352da8c2216c1238ff15e5410af0ed1
Author
Vayun Mathur <[email protected]>
When
2026-12-01 23:16 UTC (4 days ago)
Parents
8bec5bd
The pre-push backstop just rejected a push for an
environment reason, not a lint reason: under the
systemd-run push vehicle JAVA_HOME is unset and
java resolves to JVM 8, which Gradle refuses
(17+ required). Both hooks now probe for JDK 21
(the prebuilt sibling the tooling uses) or an
installed 17+ and export JAVA_HOME before invoking
Gradle, so the gate tests lint, not the shell env.

Diff

.githooks/pre-commit
diff --git a/.githooks/pre-commit b/.githooks/pre-commitindex b2246a72a8..9e21f264ef 100755--- a/.githooks/pre-commit+++ b/.githooks/pre-commit@@ -4,6 +4,13 @@ # only covers modules with a release variant; library modules use :lint. # Agents work in worktrees and never push; the parent merges into main. set -u+# Under systemd-run JAVA_HOME may be unset and `java` resolves to JVM 8,+# which Gradle rejects. Prefer JDK 21, else any installed 17+.+if [ -z "${JAVA_HOME:-}" ] || ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -Eq '"(1[7-9]|2[0-9])'; then+  for cand in /home/vayun/maos/prebuilts/jdk/jdk21/linux-x86 /usr/lib/jvm/java-17-openjdk-17.0.20.1.1-1.2.el9.x86_64 /usr/lib/jvm/java-17-openjdk; do+    if [ -x "$cand/bin/java" ]; then export JAVA_HOME="$cand"; break; fi+  done+fi branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) case "$branch" in   main|master) ;;
.githooks/pre-push
diff --git a/.githooks/pre-push b/.githooks/pre-pushindex 591f7a1439..fc60170770 100755--- a/.githooks/pre-push+++ b/.githooks/pre-push@@ -4,6 +4,14 @@ # or the pre-commit gate was bypassed). Merge-time lint is the pre-commit # hook's job; this is the second lock. set -u+# Under systemd-run (the sanctioned push vehicle) JAVA_HOME may be unset and+# `java` resolves to JVM 8, which Gradle rejects. Prefer the JDK 21 sibling+# the tooling uses, else any installed 17+.+if [ -z "${JAVA_HOME:-}" ] || ! "$JAVA_HOME/bin/java" -version 2>&1 | grep -Eq '"(1[7-9]|2[0-9])'; then+  for cand in /home/vayun/maos/prebuilts/jdk/jdk21/linux-x86 /usr/lib/jvm/java-17-openjdk-17.0.20.1.1-1.2.el9.x86_64 /usr/lib/jvm/java-17-openjdk; do+    if [ -x "$cand/bin/java" ]; then export JAVA_HOME="$cand"; break; fi+  done+fi remote="$1" zero="0000000000000000000000000000000000000000" fail=0