Skip to content

Commit 85349a2

Browse files
committed
Add support for MAVEN_PROJECTBASEDIR substitution (backport of MNG-8598)
1 parent d5c1764 commit 85349a2

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

apache-maven/src/bin/mvn

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,14 @@ find_file_argument_basedir() {
172172
)
173173
}
174174

175-
# concatenates all lines of a file
175+
# concatenates all lines of a file and replaces variables
176176
concat_lines() {
177177
if [ -f "$1" ]; then
178-
echo "`tr -s '\r\n' ' ' < "$1"`"
178+
# First transform line endings to spaces
179+
content=$(tr -s '\r\n' ' ' < "$1")
180+
# Handle both ${var} and $var formats, only substitute MAVEN_PROJECTBASEDIR
181+
echo "$content" | sed -e "s|\${MAVEN_PROJECTBASEDIR}|$MAVEN_PROJECTBASEDIR|g" \
182+
-e "s|\$MAVEN_PROJECTBASEDIR|$MAVEN_PROJECTBASEDIR|g"
179183
fi
180184
}
181185

apache-maven/src/bin/mvn.cmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ set "jvmConfig=\.mvn\jvm.config"
165165
if not exist "%MAVEN_PROJECTBASEDIR%%jvmConfig%" goto endReadAdditionalConfig
166166

167167
@setlocal EnableExtensions EnableDelayedExpansion
168-
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
168+
set JVM_CONFIG_MAVEN_OPTS=
169+
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do (
170+
set "line=%%a"
171+
set "line=!line:$MAVEN_PROJECTBASEDIR=%MAVEN_PROJECTBASEDIR%!"
172+
set "line=!line:${MAVEN_PROJECTBASEDIR}=%MAVEN_PROJECTBASEDIR%!"
173+
set JVM_CONFIG_MAVEN_OPTS=!JVM_CONFIG_MAVEN_OPTS! !line!
174+
)
169175
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
170176

171177
:endReadAdditionalConfig

0 commit comments

Comments
 (0)