Problem
The PowerShell section of the mvnw.cmd script fails to parse the maven-wrapper.properties file properly when it contains license header comments.
# Current problematic code
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
Impact
When running the Maven wrapper on Windows, execution stops with the following error:
ConvertFrom-StringData : Data missing '=' in the string.
This happens because ConvertFrom-StringData expects every non-blank line to contain an '=' sign, but the properties file begins with ASF license header comments.
Proposed Solution
Modify the PowerShell code to strip comments and blank lines before parsing:
# Fixed approach
$properties = Get-Content "$scriptDir/.mvn/wrapper/maven-wrapper.properties" |
Where-Object { $_ -match '^\s*[^#].*=' } |
ConvertFrom-StringData
$distributionUrl = $properties.distributionUrl
This also provides the benefit of reusing $properties later instead of re-reading the file (see lines 124-125 in mvnw.cmd).
References
Problem
The PowerShell section of the mvnw.cmd script fails to parse the maven-wrapper.properties file properly when it contains license header comments.
Impact
When running the Maven wrapper on Windows, execution stops with the following error:
This happens because
ConvertFrom-StringDataexpects every non-blank line to contain an '=' sign, but the properties file begins with ASF license header comments.Proposed Solution
Modify the PowerShell code to strip comments and blank lines before parsing:
This also provides the benefit of reusing $properties later instead of re-reading the file (see lines 124-125 in mvnw.cmd).
References