From a1c68554a0b3d2664135bb03bbedd7a1e234c4c9 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 17 Jun 2026 19:04:41 +0000 Subject: [PATCH] Fix mvnw: wrong MAVEN_HOME path and unzip overwrites 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 --- mvnw | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mvnw b/mvnw index 7de95bb..d8fd9d8 100755 --- 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 -- 2.39.5