Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Fix bug in Windows Maven Wrapper script #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

baincd
Copy link

@baincd baincd commented Jul 7, 2021

(I am aware that this project is frozen. However, this version of maven wrapper is still very common, including in new projects generated by Spring Initializr. Therefore, I request this be kept open as documentation for others on how to resolve this issue.)

The mvnw.cmd script that has a bug in the functionality that should loop over the .mvn/wrapper/maven-wrapper.properties, which causes the properties to not take effect. This is especially problematic in development environments that require the use of a maven repository other than Maven Central.

To fix the issue, in mvnw.cmd edit the FOR loop at lines 125-127 to add the usebackq option

FOR /F "tokens=1,2 delims== usebackq" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)

Explanation: The double quotes around the filename causes the FOR command to treat it as string. But adding the usebackq option changes the FOR command to instead treat the double-quoted string as a filename set (reference)

@jvanzyl
Copy link

jvanzyl commented Jul 13, 2021

I will integrate this and likely do a release, as the version at Apache is currently unusable for 3.x users and will continue to be.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants