镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fail fast when no download mechanism is available in mvnw - #462

Open
arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:fix/mwrapper-441-no-download-mechanism
Open

arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:fix/mwrapper-441-no-download-mechanism

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

The download block in only-mvnw tries wget, then curl, then falls back to Java, but had no final else. When none of the three are available, the if/elif chain silently falls through instead of failing, and the script only reports a confusing "failed to unzip" error from the later unzip step, which can never find a distribution archive that was never downloaded.

Adds the missing else branch to fail immediately with a clear message, and a guard right after the download block that fails if the distribution file does not exist, before any further processing. Fixes #441.

What

Fixes #441: mvnw (generated with distributionType=only-script) silently continues when none of wget, curl or a JDK are available to download the Maven distribution, instead of failing with a clear message.

How

  • Adds a final else to the wget/curl/Java download dispatch in only-mvnw, calling die with a message naming the three possible download mechanisms.
  • Adds a guard right after the download block that fails with a clear message if the distribution archive was not actually downloaded, before the script moves on to checksum validation and unzip.
  • Same approach as the previously proposed fix in Fail when only-script mvnw has no download tool #441 #443 (closed by the stale-bot for inactivity, not because it was wrong).

Tests

  • Reproduced the bug first: ran only-mvnw with PATH stripped of wget/curl/java/javac and JAVA_HOME unset against a real maven-wrapper.properties. Before the fix it printed the JAVA_HOME warning and then failed later with a confusing unzip: cannot find or open ... failed to unzip (exit 1). After the fix it fails immediately with No download mechanism available: install wget or curl, or make a JDK available on PATH / via JAVA_HOME (exit 1).
  • Ran the fixed script with a normal PATH (curl available): downloads and runs Maven 3.9.9 successfully, no regression.
  • sh -n only-mvnw: syntax OK.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
check one of the following:

The download block in only-mvnw tries wget, then curl, then falls
back to Java, but had no final else. When none of the three are
available, the if/elif chain silently falls through instead of
failing, and the script only reports a confusing "failed to unzip"
error from the later unzip step, which can never find a distribution
archive that was never downloaded.

Adds the missing else branch to fail immediately with a clear
message, and a guard right after the download block that fails if
the distribution file does not exist, before any further processing.
Fixes apache#441.
@arturobernalg
arturobernalg force-pushed the fix/mwrapper-441-no-download-mechanism branch from 4f44c30 to ff8327e Compare October 19, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mvnw silently continues when no download mechanism is available (missing final else)

1 participant