Skip to content

Commit 4d200dd

Browse files
committed
[FLUSS-2113][build] Upgrade Deployed Maven to Latest Stable Release (3.9.11)
1 parent b0a4124 commit 4d200dd

File tree

3 files changed

+94
-18
lines changed

3 files changed

+94
-18
lines changed

.mvn/wrapper/maven-wrapper.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
wrapperVersion=3.3.2
17+
wrapperVersion=3.3.4
1818
distributionType=only-script
19-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
20-
distributionSha256Sum=ccf20a80e75a17ffc34d47c5c95c98c39d426ca17d670f09cd91e877072a9309
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
20+
distributionSha512Sum=bcfe4fe305c962ace56ac7b5fc7a08b87d5abd8b7e89027ab251069faebee516b0ded8961445d6d91ec1985dfe30f8153268843c89aa392733d1a3ec956c9978

mvnw

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# ----------------------------------------------------------------------------
1919

2020
# ----------------------------------------------------------------------------
21-
# Apache Maven Wrapper startup batch script, version 3.3.2
21+
# Apache Maven Wrapper startup batch script, version 3.3.4
2222
#
2323
# Optional ENV vars
2424
# -----------------
@@ -104,14 +104,17 @@ trim() {
104104
printf "%s" "${1}" | tr -d '[:space:]'
105105
}
106106

107+
scriptDir="$(dirname "$0")"
108+
scriptName="$(basename "$0")"
109+
107110
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
108111
while IFS="=" read -r key value; do
109112
case "${key-}" in
110113
distributionUrl) distributionUrl=$(trim "${value-}") ;;
111114
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
112115
esac
113-
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
114-
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
116+
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
117+
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
115118

116119
case "${distributionUrl##*/}" in
117120
maven-mvnd-*bin.*)
@@ -129,7 +132,7 @@ maven-mvnd-*bin.*)
129132
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
130133
;;
131134
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
132-
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
135+
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
133136
esac
134137

135138
# apply MVNW_REPOURL and calculate MAVEN_HOME
@@ -226,7 +229,7 @@ if [ -n "${distributionSha256Sum-}" ]; then
226229
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
227230
exit 1
228231
elif command -v sha256sum >/dev/null; then
229-
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
232+
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
230233
distributionSha256Result=true
231234
fi
232235
elif command -v shasum >/dev/null; then
@@ -251,8 +254,41 @@ if command -v unzip >/dev/null; then
251254
else
252255
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
253256
fi
254-
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
255-
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
257+
258+
# Find the actual extracted directory name (handles snapshots where filename != directory name)
259+
actualDistributionDir=""
260+
261+
# First try the expected directory name (for regular distributions)
262+
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
263+
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
264+
actualDistributionDir="$distributionUrlNameMain"
265+
fi
266+
fi
267+
268+
# If not found, search for any directory with the Maven executable (for snapshots)
269+
if [ -z "$actualDistributionDir" ]; then
270+
# enable globbing to iterate over items
271+
set +f
272+
for dir in "$TMP_DOWNLOAD_DIR"/*; do
273+
if [ -d "$dir" ]; then
274+
if [ -f "$dir/bin/$MVN_CMD" ]; then
275+
actualDistributionDir="$(basename "$dir")"
276+
break
277+
fi
278+
fi
279+
done
280+
set -f
281+
fi
282+
283+
if [ -z "$actualDistributionDir" ]; then
284+
verbose "Contents of $TMP_DOWNLOAD_DIR:"
285+
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
286+
die "Could not find Maven distribution directory in extracted archive"
287+
fi
288+
289+
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
290+
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
291+
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
256292

257293
clean || :
258294
exec_maven "$@"

mvnw.cmd

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@REM ----------------------------------------------------------------------------
1919

2020
@REM ----------------------------------------------------------------------------
21-
@REM Apache Maven Wrapper startup batch script, version 3.3.2
21+
@REM Apache Maven Wrapper startup batch script, version 3.3.4
2222
@REM
2323
@REM Optional ENV vars
2424
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@@ -39,7 +39,7 @@
3939
@SET __MVNW_ARG0_NAME__=
4040
@SET MVNW_USERNAME=
4141
@SET MVNW_PASSWORD=
42-
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
42+
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
4343
@echo Cannot start maven from wrapper >&2 && exit /b 1
4444
@GOTO :EOF
4545
: end batch / begin powershell #>
@@ -72,16 +72,30 @@ switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
7272
# apply MVNW_REPOURL and calculate MAVEN_HOME
7373
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
7474
if ($env:MVNW_REPOURL) {
75-
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
76-
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
75+
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
76+
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
7777
}
7878
$distributionUrlName = $distributionUrl -replace '^.*/',''
7979
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
80-
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
80+
81+
$MAVEN_M2_PATH = "$HOME/.m2"
8182
if ($env:MAVEN_USER_HOME) {
82-
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
83+
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
84+
}
85+
86+
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
87+
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
88+
}
89+
90+
$MAVEN_WRAPPER_DISTS = $null
91+
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
92+
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
93+
} else {
94+
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
8395
}
84-
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
96+
97+
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
98+
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
8599
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
86100

87101
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
@@ -133,7 +147,33 @@ if ($distributionSha256Sum) {
133147

134148
# unzip and move
135149
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
136-
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
150+
151+
# Find the actual extracted directory name (handles snapshots where filename != directory name)
152+
$actualDistributionDir = ""
153+
154+
# First try the expected directory name (for regular distributions)
155+
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
156+
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
157+
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
158+
$actualDistributionDir = $distributionUrlNameMain
159+
}
160+
161+
# If not found, search for any directory with the Maven executable (for snapshots)
162+
if (!$actualDistributionDir) {
163+
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
164+
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
165+
if (Test-Path -Path $testPath -PathType Leaf) {
166+
$actualDistributionDir = $_.Name
167+
}
168+
}
169+
}
170+
171+
if (!$actualDistributionDir) {
172+
Write-Error "Could not find Maven distribution directory in extracted archive"
173+
}
174+
175+
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
176+
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
137177
try {
138178
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
139179
} catch {

0 commit comments

Comments
 (0)