You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2023/02/22 22:00:21 UTC

[maven-wrapper] branch master updated: [MWRAPPER-67] Remove '\r' from wrapperUrl when used on windows via mvnw script

This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-wrapper.git


The following commit(s) were added to refs/heads/master by this push:
     new d123f7c  [MWRAPPER-67] Remove '\r' from wrapperUrl when used on windows via mvnw script
d123f7c is described below

commit d123f7cc3cf6f62df982007573d7d4984c36bdfb
Author: Jeremy Landis <je...@hotmail.com>
AuthorDate: Tue May 17 13:22:48 2022 -0400

    [MWRAPPER-67] Remove '\r' from wrapperUrl when used on windows via mvnw script
    
    Usage of git bash will not download the maven wrapper jar along with curl (probably others) due to having windows line endings in the URL (trailing '\r').  To ensure that is not the case, make sure to strip '\r' out before usage.
    
    Use case, .mvnw in powershell will use mvnw.cmd and has no issues downloading.  If user does same in git bash, it will fail with invalid URL error with curl.  Using ./mvnw.cmd there will work but not natural usage.  To ensure this simply just works for full support, trim out carriage return feeds.
    
    note: This only affected the download.  It worked otherwise.
    
    Overall issue is due to how IFS works, it does not consider '\r'.
---
 maven-wrapper-distribution/src/resources/mvnw | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/maven-wrapper-distribution/src/resources/mvnw b/maven-wrapper-distribution/src/resources/mvnw
old mode 100755
new mode 100644
index c5abf3c..37e0a57
--- a/maven-wrapper-distribution/src/resources/mvnw
+++ b/maven-wrapper-distribution/src/resources/mvnw
@@ -199,7 +199,9 @@ else
       wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/@@project.version@@/maven-wrapper-@@project.version@@.jar"
     fi
     while IFS="=" read -r key value; do
-      case "$key" in (wrapperUrl) wrapperUrl="$value"; break ;;
+      # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
+      safeValue=$(echo "$value" | tr -d '\r')
+      case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
       esac
     done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
     log "Downloading from: $wrapperUrl"