Fix Maven wrapper support for snapshot distributions#335
Merged
gnodet merged 2 commits intoapache:masterfrom Jul 22, 2025
Merged
Fix Maven wrapper support for snapshot distributions#335gnodet merged 2 commits intoapache:masterfrom
gnodet merged 2 commits intoapache:masterfrom
Conversation
maven-wrapper-plugin/src/it/projects/snapshot_distribution/verify.groovy
Outdated
Show resolved
Hide resolved
maven-wrapper-plugin/src/it/projects/snapshot_distribution/verify.groovy
Outdated
Show resolved
Hide resolved
slawekjaranowski
approved these changes
Jul 15, 2025
The Maven wrapper scripts (only-mvnw and only-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: - Filename: apache-maven-4.1.0-20250710.120440-1-bin.zip - Directory: apache-maven-4.1.0-SNAPSHOT/ This mismatch caused the script to fail when trying to access the extracted directory. Changes: - Modified only-mvnw to dynamically detect the actual extracted directory by looking for the Maven executable instead of assuming the name - Applied the same fix to only-mvnw.cmd for Windows compatibility - Added comprehensive tests in SnapshotDistributionTest.java - Added integration test for snapshot distribution handling - Updated documentation to mention snapshot support The fix maintains backward compatibility with regular releases while enabling support for Maven snapshot distributions. Fixes: apache/maven#10894 (comment)
7e63da1 to
82c9403
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-mvnwandonly-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.zipapache-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.javawith unit tests for snapshot URL handlingUpdated Documentation:
index.mdto 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.zipFixes #10894 (comment)
Pull Request opened by Augment Code with guidance from the PR author