Skip to content

Commit 1149c75

Browse files
authored
[MWRAPPER-139] Remove trailing whitespace from fields in maven-wrapper.properties (#139)
This prevents issues due to confusion between CRLF and LF when running in more exotic locations such as MINGW on Windows but using ./mvnw rather than ./mvnw.cmd. A prime example of where this is an issue would be on windows-latest GitHub Actions runners. Fixes MWRAPPER-139, MWRAPPER-137. --- https://issues.apache.org/jira/browse/MWRAPPER-139 https://issues.apache.org/jira/browse/MWRAPPER-137 https://issues.apache.org/jira/browse/MWRAPPER-136
1 parent 038d300 commit 1149c75

File tree

1 file changed

+10
-2
lines changed
  • maven-wrapper-distribution/src/resources

1 file changed

+10
-2
lines changed

maven-wrapper-distribution/src/resources/only-mvnw

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,19 @@ die() {
9797
exit 1
9898
}
9999

100+
trim() {
101+
# MWRAPPER-139:
102+
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
103+
# Needed for removing poorly interpreted newline sequences when running in more
104+
# exotic environments such as mingw bash on Windows.
105+
printf "%s" "${1}" | tr -d '[:space:]'
106+
}
107+
100108
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
101109
while IFS="=" read -r key value; do
102110
case "${key-}" in
103-
distributionUrl) distributionUrl="${value-}" ;;
104-
distributionSha256Sum) distributionSha256Sum="${value-}" ;;
111+
distributionUrl) distributionUrl=$(trim "${value-}") ;;
112+
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
105113
esac
106114
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
107115
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"

0 commit comments

Comments
 (0)