Fix Maven wrapper support for snapshot distributions #335
+372
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The Maven wrapper scripts (
only-mvnw
andonly-mvnw.cmd
) previously failed when using snapshot distributions because they assumed the directory name inside the ZIP file would match the filename pattern. However, for snapshots:apache-maven-4.1.0-20250710.120440-1-bin.zip
apache-maven-4.1.0-SNAPSHOT/
This mismatch caused the script to fail when trying to access the extracted directory, as reported in apache/maven#10894 (comment).
Solution
This PR implements dynamic directory detection instead of assuming directory names match filename patterns:
Changes Made
Fixed Unix Shell Script (
only-mvnw
):Fixed Windows PowerShell Script (
only-mvnw.cmd
):Added Comprehensive Tests:
SnapshotDistributionTest.java
with unit tests for snapshot URL handlingUpdated Documentation:
index.md
to mention snapshot support with example URLsKey Benefits
Testing
Example Usage
After this fix, users can use snapshot distributions like:
distributionUrl=https://repository.apache.org/content/repositories/snapshots/org/apache/maven/apache-maven/4.1.0-SNAPSHOT/apache-maven-4.1.0-20250710.120440-1-bin.zip
Fixes #10894 (comment)
Pull Request opened by Augment Code with guidance from the PR author