You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2025/07/18 09:52:10 UTC
(maven-wrapper) 01/01: Add busybox wget support as fallback in only-mvnw script
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch origin-feature-jdk-enhancement
in repository https://gitbox.apache.org/repos/asf/maven-wrapper.git
commit cb49488c19401a00f4c7440d7553f5c39e4fa2da
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jul 18 11:51:14 2025 +0200
Add busybox wget support as fallback in only-mvnw script
- Enhanced only-mvnw script to try busybox wget when neither wget nor curl is available
- Added busybox wget detection in all HTTP request functions:
* resolve_jdk_url() for JDK URL resolution API calls
* redirect URL resolution logic
* get_latest_version_from_disco() for version API calls
* install_jdk() for JDK file downloads
* main Maven distribution download section
- Updated error messages to include busybox wget as supported option
- Updated integration tests to handle busybox wget error messages
- Improves compatibility with minimal Linux environments like Alpine containers
---
maven-wrapper-distribution/src/resources/only-mvnw | 17 ++++++++++++++---
.../it/projects/jdk_checksum_verification/verify.groovy | 2 +-
.../src/it/projects/type_only-script-fail/verify.groovy | 2 +-
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/maven-wrapper-distribution/src/resources/only-mvnw b/maven-wrapper-distribution/src/resources/only-mvnw
index 4ac0a96..a547dda 100755
--- a/maven-wrapper-distribution/src/resources/only-mvnw
+++ b/maven-wrapper-distribution/src/resources/only-mvnw
@@ -196,8 +196,10 @@ resolve_jdk_url() {
_resolve_api_response="$(curl -s -f "$_resolve_disco_api_url" 2>/dev/null)"
elif command -v wget >/dev/null; then
_resolve_api_response="$(wget -q -O - "$_resolve_disco_api_url" 2>/dev/null)"
+ elif command -v busybox >/dev/null && busybox wget --help >/dev/null 2>&1; then
+ _resolve_api_response="$(busybox wget -q -O - "$_resolve_disco_api_url" 2>/dev/null)"
else
- die "Cannot resolve JDK URL: curl or wget required"
+ die "Cannot resolve JDK URL: curl, wget, or busybox wget required"
fi
if [ -z "$_resolve_api_response" ]; then
@@ -216,6 +218,8 @@ resolve_jdk_url() {
_resolve_download_url="$(curl -s -I "$_resolve_redirect_url" 2>/dev/null | grep -i '^location:' | cut -d' ' -f2- | tr -d '\r\n')"
elif command -v wget >/dev/null; then
_resolve_download_url="$(wget -q -S -O /dev/null "$_resolve_redirect_url" 2>&1 | grep -i '^ location:' | cut -d' ' -f4- | tr -d '\r\n')"
+ elif command -v busybox >/dev/null && busybox wget --help >/dev/null 2>&1; then
+ _resolve_download_url="$(busybox wget -q -S -O /dev/null "$_resolve_redirect_url" 2>&1 | grep -i '^ location:' | cut -d' ' -f4- | tr -d '\r\n')"
else
# Fallback to using the redirect URL directly
_resolve_download_url="$_resolve_redirect_url"
@@ -334,8 +338,10 @@ get_latest_version_from_disco() {
api_response="$(curl -s -f "$disco_api_url" 2>/dev/null)"
elif command -v wget >/dev/null; then
api_response="$(wget -q -O - "$disco_api_url" 2>/dev/null)"
+ elif command -v busybox >/dev/null && busybox wget --help >/dev/null 2>&1; then
+ api_response="$(busybox wget -q -O - "$disco_api_url" 2>/dev/null)"
else
- verbose "No HTTP client (curl/wget) available for Disco API"
+ verbose "No HTTP client (curl/wget/busybox wget) available for Disco API"
return 1 # No HTTP client available
fi
@@ -508,8 +514,10 @@ install_jdk() {
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$url" -O "$jdk_file" || die "wget: Failed to fetch JDK from $url"
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$jdk_file" "$url" || die "curl: Failed to fetch JDK from $url"
+ elif [ -z "${MVNW_USERNAME-}" ] && command -v busybox >/dev/null && busybox wget --help >/dev/null 2>&1; then
+ busybox wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$url" -O "$jdk_file" || die "busybox wget: Failed to fetch JDK from $url"
else
- die "Cannot download JDK: wget or curl required"
+ die "Cannot download JDK: wget, curl, or busybox wget required"
fi
# Verify checksum if provided
@@ -670,6 +678,9 @@ if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
verbose "Found curl ... using curl"
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
+elif [ -z "${MVNW_USERNAME-}" ] && command -v busybox >/dev/null && busybox wget --help >/dev/null 2>&1; then
+ verbose "Found busybox wget ... using busybox wget"
+ busybox wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "busybox wget: Failed to fetch $distributionUrl"
elif set_java_home; then
verbose "Falling back to use Java to download"
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
diff --git a/maven-wrapper-plugin/src/it/projects/jdk_checksum_verification/verify.groovy b/maven-wrapper-plugin/src/it/projects/jdk_checksum_verification/verify.groovy
index 225b9df..64ed1a2 100644
--- a/maven-wrapper-plugin/src/it/projects/jdk_checksum_verification/verify.groovy
+++ b/maven-wrapper-plugin/src/it/projects/jdk_checksum_verification/verify.groovy
@@ -44,7 +44,7 @@ assert log.contains('[INFO] Unpacked only-script type wrapper distribution')
// 2. Network issues preventing download
// 3. System JDK usage (if JDK download is skipped)
boolean checksumFailure = log.contains("checksum") || log.contains("SHA-256") || log.contains("verification")
-boolean networkIssue = log.contains("Failed to fetch") || log.contains("curl:") || log.contains("wget:")
+boolean networkIssue = log.contains("Failed to fetch") || log.contains("curl:") || log.contains("wget:") || log.contains("busybox wget:")
// The test should either fail checksum verification or use system JDK
assert checksumFailure || networkIssue || systemJdkUsed, "Either checksum verification should occur, network issue encountered, or system JDK should be used"
diff --git a/maven-wrapper-plugin/src/it/projects/type_only-script-fail/verify.groovy b/maven-wrapper-plugin/src/it/projects/type_only-script-fail/verify.groovy
index 8bcdfbf..c33f4b9 100644
--- a/maven-wrapper-plugin/src/it/projects/type_only-script-fail/verify.groovy
+++ b/maven-wrapper-plugin/src/it/projects/type_only-script-fail/verify.groovy
@@ -27,5 +27,5 @@ if (isWindows) {
} else {
// on non-Windows: verify clear messages as well
// cover all methods: point is, there is no Maven version 0.0.0
- assert log.contains('wget: Failed to fetch') || log.contains('curl: Failed to fetch') || log.contains('- Error downloading:')
+ assert log.contains('wget: Failed to fetch') || log.contains('curl: Failed to fetch') || log.contains('busybox wget: Failed to fetch') || log.contains('- Error downloading:')
}