maven-wrapper icon indicating copy to clipboard operation
maven-wrapper copied to clipboard

[MWRAPPER-114] Maven wrapper relative distributionUrl does not work on Windows

Open jira-importer opened this issue 2 years ago • 3 comments

Edward Woolhouse opened MWRAPPER-114 and commented

If Maven Wrapper is used with a relative distributionUrl on Windows then an error message indicating invalid path characters is shown.

 

1. Directory structure 
./mvnw
./mvnw.cmd
./.mvn/wrapper/maven-wrapper.jar
./.mvn/wrapper/maven-wrapper.properties
...
1. maven-wrapper.properties
distributionUrl=apache-maven-3.8.8-bin.zip
wrapperUrl=maven-wrapper.jar

When run

./mvnw

...
java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/some-path/apache-maven-3.8.8.zip 

This is caused by PathAssembler.java:getBaseName unnecessarilly stringifying the distibution URL. The fix is as follows

    private String getBaseName(URI distUrl) {
-       return Paths.get(distUrl.getPath()).getFileName().toString();
+       return Paths.get(distUrl).getFileName().toString();
    }

 


Affects: 3.2.0

Remote Links:

jira-importer avatar Aug 10 '23 19:08 jira-importer

Edward Woolhouse commented

Well, it's not as simple a fix as that, as this fix would break the ability to use non-local paths. Needs a little more thought. Maybe special handling for the file:/// scheme?

jira-importer avatar Aug 10 '23 20:08 jira-importer

Edward Woolhouse commented

Pull request raised https://github.com/apache/maven-wrapper/pull/107

jira-importer avatar Aug 14 '23 05:08 jira-importer

Edward Woolhouse commented

The above comment

The proposed fix does not actually fix the reported issue.
Relative paths, such as `distributionUrl=apache-maven-3.8.8-bin.zip` does not have a `file` schema nor use a full local path (as per the tests provided).
Or did I miss something? 

was withdrawn and deleted with a message along the lines of 'I've tested it, it does work after all'

The bot helpfully copied the first comment, but not the retraction. Is anyone able ot push this over the line? I'm happy to address any issues people have with it.

jira-importer avatar Sep 18 '24 08:09 jira-importer