]> juplo.de Git - maven-thymeleaf-skin/commitdiff
Fix mvnw: wrong MAVEN_HOME path and unzip overwrites
authorKai Moritz <kai.milan.moritz@googlemail.com>
Wed, 17 Jun 2026 19:04:41 +0000 (19:04 +0000)
committerKai Moritz <kai@juplo.de>
Wed, 17 Jun 2026 20:05:58 +0000 (22:05 +0200)
Two bugs introduced in the initial mvnw script:

1. apache-maven-3.9.6-bin.zip extracts into apache-maven-3.9.6/ (without
   the -bin suffix), but MAVEN_HOME was set to $DISTRIBUTION_ID which
   includes -bin. Fix: strip -bin suffix with ${DISTRIBUTION_ID%-bin}.

2. unzip without -o flag asks interactively when the cache directory
   already contains files from a previous (partial) run. Fix: add -o
   (overwrite silently).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mvnw

diff --git a/mvnw b/mvnw
index 7de95bb0a8b225eb66d29933e37a29f28a1ca901..d8fd9d838b5be2d63fe4d1e9a583083a277b84d6 100755 (executable)
--- a/mvnw
+++ b/mvnw
@@ -134,7 +134,8 @@ else
 fi
 
 DISTRIBUTION_CACHE_DIR="$DISTRIBUTION_DIR/$URL_HASH"
-MAVEN_HOME="$DISTRIBUTION_CACHE_DIR/$DISTRIBUTION_ID"
+# The -bin.zip extracts into a directory without the -bin suffix
+MAVEN_HOME="$DISTRIBUTION_CACHE_DIR/${DISTRIBUTION_ID%-bin}"
 
 if [ ! -x "$MAVEN_HOME/bin/mvn" ]; then
   mkdir -p "$DISTRIBUTION_CACHE_DIR"
@@ -186,7 +187,7 @@ if [ ! -x "$MAVEN_HOME/bin/mvn" ]; then
   fi
 
   log "Extracting to $DISTRIBUTION_CACHE_DIR"
-  unzip -q "$DOWNLOAD_FILE" -d "$DISTRIBUTION_CACHE_DIR"
+  unzip -q -o "$DOWNLOAD_FILE" -d "$DISTRIBUTION_CACHE_DIR"
   rm -f "$DOWNLOAD_FILE"
 
   if [ ! -x "$MAVEN_HOME/bin/mvn" ]; then