Skip to content

Fix: Maven Wrapper breaks on systems without unzip command #186

@coderabbitai

Description

@coderabbitai

Issue Description

When running the Maven wrapper on systems without the unzip command installed, the wrapper fails to properly install Maven.

Technical Details

The issue occurs in mvnw script when it detects unzip is unavailable and switches to using .tar.gz format:

# select .zip or .tar.gz
if ! command -v unzip >/dev/null; then
  distributionUrl="${distributionUrl%.zip}.tar.gz"
  distributionUrlName="${distributionUrl##*/}"
fi

However, the script doesn't update the distributionUrlNameMain variable which was derived earlier from the original filename. This variable is used later for directory operations, causing the installation to fail on systems without unzip.

Suggested Fix

Update the code to recalculate distributionUrlNameMain after changing the file extension:

-  distributionUrl="${distributionUrl%.zip}.tar.gz"
-  distributionUrlName="${distributionUrl##*/}"
+  distributionUrl="${distributionUrl%.zip}.tar.gz"
+  distributionUrlName="${distributionUrl##*/}"
+  # keep the "main" name in sync with the new extension
+  distributionUrlNameMain="${distributionUrlName%.*}"
+  distributionUrlNameMain="${distributionUrlNameMain%-bin}"

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions