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

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

commit 3de0708945e79a9658298e81c748437740592ba5
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue May 21 15:03:31 2024 +0200

    [MWRAPPER-140] only-script type does not honor MAVEN_USER_HOME
    
    User provided patch
    
    ---
    
    https://issues.apache.org/jira/browse/MWRAPPER-140
---
 maven-wrapper-distribution/src/resources/only-mvnw     | 3 ++-
 maven-wrapper-distribution/src/resources/only-mvnw.cmd | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/maven-wrapper-distribution/src/resources/only-mvnw 
b/maven-wrapper-distribution/src/resources/only-mvnw
index 9ae209d..02b2e72 100755
--- a/maven-wrapper-distribution/src/resources/only-mvnw
+++ b/maven-wrapper-distribution/src/resources/only-mvnw
@@ -139,7 +139,8 @@ esac
 distributionUrlName="${distributionUrl##*/}"
 distributionUrlNameMain="${distributionUrlName%.*}"
 distributionUrlNameMain="${distributionUrlNameMain%-bin}"
-MAVEN_HOME="$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string 
"$distributionUrl")"
+MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
+MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string
 "$distributionUrl")"
 
 exec_maven() {
   unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
diff --git a/maven-wrapper-distribution/src/resources/only-mvnw.cmd 
b/maven-wrapper-distribution/src/resources/only-mvnw.cmd
index da5a302..d3e39f4 100644
--- a/maven-wrapper-distribution/src/resources/only-mvnw.cmd
+++ b/maven-wrapper-distribution/src/resources/only-mvnw.cmd
@@ -79,6 +79,9 @@ if ($env:MVNW_REPOURL) {
 $distributionUrlName = $distributionUrl -replace '^.*/',''
 $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' 
-replace '-bin$',''
 $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
+if ($env:MAVEN_USER_HOME) {
+  $MAVEN_HOME_PARENT = 
"$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
+}
 $MAVEN_HOME_NAME = 
([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl)
 | ForEach-Object {$_.ToString("x2")}) -join ''
 $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
 

Reply via email to