arturobernalg opened a new pull request, #462:
URL: https://github.com/apache/maven-wrapper/pull/462

   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.
   
   Claude-Session: https://claude.ai/code/session_01ReVkpYAznRPFBkHQFwYWcK
   
   ### 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 #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](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to