summaryrefslogtreecommitdiff
path: root/mvnw
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2025-11-02 17:38:02 +0200
committerGravatar Uko Kokņevičs2026-01-10 16:18:09 +0200
commit03e46ed58ad195b76e1d9955e8ef7e881b3506cf (patch)
treee3ab6c068fe1c2e6c7b1e499b41a650230c16d8c /mvnw
parentRemove shellcheck-precommit (diff)
downloadlv.enes:parent-03e46ed58ad195b76e1d9955e8ef7e881b3506cf.tar.gz
lv.enes:parent-03e46ed58ad195b76e1d9955e8ef7e881b3506cf.tar.xz
lv.enes:parent-03e46ed58ad195b76e1d9955e8ef7e881b3506cf.zip
Update wrapper-plugin
Diffstat (limited to 'mvnw')
-rwxr-xr-xmvnw50
1 files changed, 43 insertions, 7 deletions
diff --git a/mvnw b/mvnw
index 19529dd..bd8896b 100755
--- a/mvnw
+++ b/mvnw
@@ -19,7 +19,7 @@
19# ---------------------------------------------------------------------------- 19# ----------------------------------------------------------------------------
20 20
21# ---------------------------------------------------------------------------- 21# ----------------------------------------------------------------------------
22# Apache Maven Wrapper startup batch script, version 3.3.2 22# Apache Maven Wrapper startup batch script, version 3.3.4
23# 23#
24# Optional ENV vars 24# Optional ENV vars
25# ----------------- 25# -----------------
@@ -105,14 +105,17 @@ trim() {
105 printf "%s" "${1}" | tr -d '[:space:]' 105 printf "%s" "${1}" | tr -d '[:space:]'
106} 106}
107 107
108scriptDir="$(dirname "$0")"
109scriptName="$(basename "$0")"
110
108# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties 111# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
109while IFS="=" read -r key value; do 112while IFS="=" read -r key value; do
110 case "${key-}" in 113 case "${key-}" in
111 distributionUrl) distributionUrl=$(trim "${value-}") ;; 114 distributionUrl) distributionUrl=$(trim "${value-}") ;;
112 distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; 115 distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
113 esac 116 esac
114done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" 117done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
115[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" 118[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
116 119
117case "${distributionUrl##*/}" in 120case "${distributionUrl##*/}" in
118maven-mvnd-*bin.*) 121maven-mvnd-*bin.*)
@@ -130,7 +133,7 @@ maven-mvnd-*bin.*)
130 distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" 133 distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
131 ;; 134 ;;
132maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; 135maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
133*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; 136*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
134esac 137esac
135 138
136# apply MVNW_REPOURL and calculate MAVEN_HOME 139# apply MVNW_REPOURL and calculate MAVEN_HOME
@@ -227,7 +230,7 @@ if [ -n "${distributionSha256Sum-}" ]; then
227 echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 230 echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
228 exit 1 231 exit 1
229 elif command -v sha256sum >/dev/null; then 232 elif command -v sha256sum >/dev/null; then
230 if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then 233 if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
231 distributionSha256Result=true 234 distributionSha256Result=true
232 fi 235 fi
233 elif command -v shasum >/dev/null; then 236 elif command -v shasum >/dev/null; then
@@ -252,8 +255,41 @@ if command -v unzip >/dev/null; then
252else 255else
253 tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" 256 tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
254fi 257fi
255printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" 258
256mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" 259# Find the actual extracted directory name (handles snapshots where filename != directory name)
260actualDistributionDir=""
261
262# First try the expected directory name (for regular distributions)
263if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
264 if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
265 actualDistributionDir="$distributionUrlNameMain"
266 fi
267fi
268
269# If not found, search for any directory with the Maven executable (for snapshots)
270if [ -z "$actualDistributionDir" ]; then
271 # enable globbing to iterate over items
272 set +f
273 for dir in "$TMP_DOWNLOAD_DIR"/*; do
274 if [ -d "$dir" ]; then
275 if [ -f "$dir/bin/$MVN_CMD" ]; then
276 actualDistributionDir="$(basename "$dir")"
277 break
278 fi
279 fi
280 done
281 set -f
282fi
283
284if [ -z "$actualDistributionDir" ]; then
285 verbose "Contents of $TMP_DOWNLOAD_DIR:"
286 verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
287 die "Could not find Maven distribution directory in extracted archive"
288fi
289
290verbose "Found extracted Maven distribution directory: $actualDistributionDir"
291printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
292mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
257 293
258clean || : 294clean || :
259exec_maven "$@" 295exec_maven "$@"