gnodet-bot commented on code in PR #982:
URL: https://github.com/apache/maven/pull/982#discussion_r4018697069


##########
apache-maven/src/bin/mvn.ps1:
##########
@@ -0,0 +1,158 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Startup Script
+
+Environment Variable Prerequisites
+
+  JAVA_HOME       (Optional) Points to a Java installation.
+  MAVEN_ARGS      (Optional) Arguments passed to Maven before CLI arguments.
+  MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+  MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+-----------------------------------------------------------------------------
+#>
+
+if (-not $env:MAVEN_SKIP_RC) {
+  if (Test-Path -Path $env:PROGRAMDATA\mavenrc.ps1 -PathType Leaf) { 
&$env:PROGRAMDATA"\mavenrc.ps1" $args }
+  if (Test-Path -Path $env:USERPROFILE\mavenrc.ps1 -PathType Leaf) { 
&$env:USERPROFILE"\mavenrc.ps1" $args }
+}
+
+if (-not (Test-path $env:JAVA_HOME)) {
+  try {
+    $JAVACMD = (get-command java).Source
+  } catch {
+    Write-Error -ErrorAction Stop -Message "The $env:JAVA_HOME has not been 
set, JAVA_HOME environment variable is not defined correctly, so Apache Maven 
cannot be started."
+  }
+}
+else {
+  $JAVACMD = $env:JAVA_HOME + "\bin\java.exe"
+}
+
+if (-not (Test-Path $JAVACMD)) {
+  Write-Error -Message "The JAVA_HOME environment variable is not defined 
correctly, so Apache Maven cannot be started."
+  $ERROR_MESSAGE = "JAVA_HOME is set to " + $env:JAVA_HOME + ", but " + 
$JAVACMD + " does not exist."
+  Write-Error -ErrorAction Stop -Message $ERROR_MESSAGE
+}
+
+# check mvn home
+$MAVEN_HOME = (Get-Item $PSScriptRoot).Parent
+
+# check if maven command exists
+if (-not (Test-path "$MAVEN_HOME\bin\mvn.ps1")) {
+    Write-Error -Message "maven command (\bin\mvn.ps1) cannot be found" 
-ErrorAction Stop
+}
+# ==== END VALIDATION ====
+
+$CLASSWORLDS_CONF = "$MAVEN_HOME\bin\m2.conf"
+
+# Find the project basedir, i.e., the directory that contains the directory 
".mvn".
+# Fallback to current working directory if not found.
+
+$WDIR = Get-Location
+
+# Look for the --file switch and start the search for the .mvn directory from 
the specified
+# POM location, if supplied.
+
+$i = 0
+$file_flag_found = $false
+foreach ($arg in $args) {
+  if (($arg -ceq "-f") -or ($arg -ceq "--file")) {
+    $file_flag_found = $true
+    break
+  }
+  $i += 1
+}
+
+function IsNotRoot {
+  param (
+    [String] $path
+  )
+  $root_path_base_name = ((get-item $path).Root.BaseName
+  $path_base_name = ((get-item $path).BaseName

Review Comment:
   ⛔ **Parse error — unbalanced parentheses.** Both lines have two opening 
parens and one closing paren. PowerShell will refuse to parse this script 
entirely — `IsNotRoot` never loads, the `.mvn` directory traversal never 
executes, and `$basedir` is never set correctly.
   
   ```suggestion
     $root_path_base_name = (Get-Item $path).Root.BaseName
     $path_base_name = (Get-Item $path).BaseName
   ```



##########
apache-maven/src/bin/mvn.ps1:
##########
@@ -0,0 +1,158 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Startup Script
+
+Environment Variable Prerequisites
+
+  JAVA_HOME       (Optional) Points to a Java installation.
+  MAVEN_ARGS      (Optional) Arguments passed to Maven before CLI arguments.
+  MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+  MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+-----------------------------------------------------------------------------
+#>
+
+if (-not $env:MAVEN_SKIP_RC) {
+  if (Test-Path -Path $env:PROGRAMDATA\mavenrc.ps1 -PathType Leaf) { 
&$env:PROGRAMDATA"\mavenrc.ps1" $args }
+  if (Test-Path -Path $env:USERPROFILE\mavenrc.ps1 -PathType Leaf) { 
&$env:USERPROFILE"\mavenrc.ps1" $args }
+}
+
+if (-not (Test-path $env:JAVA_HOME)) {
+  try {
+    $JAVACMD = (get-command java).Source
+  } catch {
+    Write-Error -ErrorAction Stop -Message "The $env:JAVA_HOME has not been 
set, JAVA_HOME environment variable is not defined correctly, so Apache Maven 
cannot be started."
+  }
+}
+else {
+  $JAVACMD = $env:JAVA_HOME + "\bin\java.exe"
+}
+
+if (-not (Test-Path $JAVACMD)) {
+  Write-Error -Message "The JAVA_HOME environment variable is not defined 
correctly, so Apache Maven cannot be started."
+  $ERROR_MESSAGE = "JAVA_HOME is set to " + $env:JAVA_HOME + ", but " + 
$JAVACMD + " does not exist."
+  Write-Error -ErrorAction Stop -Message $ERROR_MESSAGE
+}
+
+# check mvn home
+$MAVEN_HOME = (Get-Item $PSScriptRoot).Parent
+
+# check if maven command exists
+if (-not (Test-path "$MAVEN_HOME\bin\mvn.ps1")) {
+    Write-Error -Message "maven command (\bin\mvn.ps1) cannot be found" 
-ErrorAction Stop
+}
+# ==== END VALIDATION ====
+
+$CLASSWORLDS_CONF = "$MAVEN_HOME\bin\m2.conf"
+
+# Find the project basedir, i.e., the directory that contains the directory 
".mvn".
+# Fallback to current working directory if not found.
+
+$WDIR = Get-Location
+
+# Look for the --file switch and start the search for the .mvn directory from 
the specified
+# POM location, if supplied.
+
+$i = 0
+$file_flag_found = $false
+foreach ($arg in $args) {
+  if (($arg -ceq "-f") -or ($arg -ceq "--file")) {
+    $file_flag_found = $true
+    break
+  }
+  $i += 1
+}
+
+function IsNotRoot {
+  param (
+    [String] $path
+  )
+  $root_path_base_name = ((get-item $path).Root.BaseName
+  $path_base_name = ((get-item $path).BaseName
+
+  return $root_path_base_name -ne $path_base_name
+}
+
+function RetrieveContentsJvmConfig {
+  param (
+    [String] $path
+  )
+
+  $jvm_location = $path + "\.mvn\jvm.config"
+
+  if (Test-Path $jvm_location) {
+    return $env:MAVEN_OPTS + " " + -Join (Get-Content $jvm_location)
+  }
+  return $env:MAVEN_OPTS
+}
+
+$basedir = ""
+
+if ($file_flag_found) {
+  # we need to assess if the file exists
+  # and then search for the maven project base dir. 
+  $pom_file_reference = $args[$i + 1]
+
+  if (Test-Path $pom_file_reference) {
+    $basedir = (Get-Item $pom_file_reference).DirectoryName
+  }
+  else {
+    $pom_file_error = "POM file " + $pom_file_reference + " specified the 
-f/--file command-line argument does not exist"
+    Write-Error -Message $pom_file_error -ErrorAction Stop
+  }
+}
+else {
+  # if file flag is not found, then the pom.xml is relative to the working dir 
+  # and the jvm.config can be found in the maven project base dir. 
+
+  $basedir = $WDIR
+
+  while (IsNotRoot($WDIR.Path)) {
+    if (Test-Path "$WDIR\.mvn") {
+      $basedir = $WDIR
+      break
+    }
+
+    if ($WDIR) {
+      $WDIR = Split-Path $WDIR      
+    }
+    else {
+      break
+    }  
+  }
+}
+
+$MAVEN_OPTS = (RetrieveContentsJvmConfig $basedir)
+
+$LAUNCHER_JAR = Get-Item $MAVEN_HOME"\boot\plexus-classworlds*.jar"
+$LAUNCHER_CLASS = "org.codehaus.plexus.classworlds.launcher.Launcher"
+
+& $JAVACMD `
+  $MAVEN_OPTS `
+  $MAVEN_DEBUG_OPTS `
+  -classpath $LAUNCHER_JAR `
+  "-Dclassworlds.conf=$CLASSWORLDS_CONF" `
+  "-Dmaven.home=$MAVEN_HOME" `
+  "-Dlibrary.jansi.path=$MAVEN_HOME\lib\jansi-native" `
+  "-Dmaven.multiModuleProjectDirectory=$basedir" `
+  $LAUNCHER_CLASS `
+  $MAVEN_ARGS `

Review Comment:
   ⛔ **`$MAVEN_ARGS` is an unset local variable — `MAVEN_ARGS` environment 
variable is silently ignored.** The correct form is `$env:MAVEN_ARGS`. PR #878 
(`run.ps1`) already has this fix.
   
   ```suggestion
     $env:MAVEN_ARGS `
   ```



##########
apache-maven/src/bin/mvn.ps1:
##########
@@ -0,0 +1,158 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Startup Script
+
+Environment Variable Prerequisites
+
+  JAVA_HOME       (Optional) Points to a Java installation.
+  MAVEN_ARGS      (Optional) Arguments passed to Maven before CLI arguments.
+  MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+  MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+-----------------------------------------------------------------------------
+#>
+
+if (-not $env:MAVEN_SKIP_RC) {
+  if (Test-Path -Path $env:PROGRAMDATA\mavenrc.ps1 -PathType Leaf) { 
&$env:PROGRAMDATA"\mavenrc.ps1" $args }
+  if (Test-Path -Path $env:USERPROFILE\mavenrc.ps1 -PathType Leaf) { 
&$env:USERPROFILE"\mavenrc.ps1" $args }
+}
+
+if (-not (Test-path $env:JAVA_HOME)) {
+  try {
+    $JAVACMD = (get-command java).Source
+  } catch {
+    Write-Error -ErrorAction Stop -Message "The $env:JAVA_HOME has not been 
set, JAVA_HOME environment variable is not defined correctly, so Apache Maven 
cannot be started."
+  }
+}
+else {
+  $JAVACMD = $env:JAVA_HOME + "\bin\java.exe"
+}
+
+if (-not (Test-Path $JAVACMD)) {
+  Write-Error -Message "The JAVA_HOME environment variable is not defined 
correctly, so Apache Maven cannot be started."
+  $ERROR_MESSAGE = "JAVA_HOME is set to " + $env:JAVA_HOME + ", but " + 
$JAVACMD + " does not exist."
+  Write-Error -ErrorAction Stop -Message $ERROR_MESSAGE
+}
+
+# check mvn home
+$MAVEN_HOME = (Get-Item $PSScriptRoot).Parent
+
+# check if maven command exists
+if (-not (Test-path "$MAVEN_HOME\bin\mvn.ps1")) {
+    Write-Error -Message "maven command (\bin\mvn.ps1) cannot be found" 
-ErrorAction Stop
+}
+# ==== END VALIDATION ====
+
+$CLASSWORLDS_CONF = "$MAVEN_HOME\bin\m2.conf"
+
+# Find the project basedir, i.e., the directory that contains the directory 
".mvn".
+# Fallback to current working directory if not found.
+
+$WDIR = Get-Location
+
+# Look for the --file switch and start the search for the .mvn directory from 
the specified
+# POM location, if supplied.
+
+$i = 0
+$file_flag_found = $false
+foreach ($arg in $args) {
+  if (($arg -ceq "-f") -or ($arg -ceq "--file")) {
+    $file_flag_found = $true
+    break
+  }
+  $i += 1
+}
+
+function IsNotRoot {
+  param (
+    [String] $path
+  )
+  $root_path_base_name = ((get-item $path).Root.BaseName
+  $path_base_name = ((get-item $path).BaseName
+
+  return $root_path_base_name -ne $path_base_name
+}
+
+function RetrieveContentsJvmConfig {
+  param (
+    [String] $path
+  )
+
+  $jvm_location = $path + "\.mvn\jvm.config"
+
+  if (Test-Path $jvm_location) {
+    return $env:MAVEN_OPTS + " " + -Join (Get-Content $jvm_location)
+  }
+  return $env:MAVEN_OPTS
+}
+
+$basedir = ""
+
+if ($file_flag_found) {
+  # we need to assess if the file exists
+  # and then search for the maven project base dir. 
+  $pom_file_reference = $args[$i + 1]
+
+  if (Test-Path $pom_file_reference) {
+    $basedir = (Get-Item $pom_file_reference).DirectoryName
+  }
+  else {
+    $pom_file_error = "POM file " + $pom_file_reference + " specified the 
-f/--file command-line argument does not exist"
+    Write-Error -Message $pom_file_error -ErrorAction Stop
+  }
+}
+else {
+  # if file flag is not found, then the pom.xml is relative to the working dir 
+  # and the jvm.config can be found in the maven project base dir. 
+
+  $basedir = $WDIR
+
+  while (IsNotRoot($WDIR.Path)) {
+    if (Test-Path "$WDIR\.mvn") {
+      $basedir = $WDIR
+      break
+    }
+
+    if ($WDIR) {
+      $WDIR = Split-Path $WDIR      
+    }
+    else {
+      break
+    }  
+  }
+}
+
+$MAVEN_OPTS = (RetrieveContentsJvmConfig $basedir)
+
+$LAUNCHER_JAR = Get-Item $MAVEN_HOME"\boot\plexus-classworlds*.jar"
+$LAUNCHER_CLASS = "org.codehaus.plexus.classworlds.launcher.Launcher"
+
+& $JAVACMD `
+  $MAVEN_OPTS `
+  $MAVEN_DEBUG_OPTS `

Review Comment:
   ⛔ **Scope mismatch with `mvnDebug.ps1`.** `mvnDebug.ps1` sets 
`$env:MAVEN_DEBUG_OPTS` (an environment variable), but this line reads 
`$MAVEN_DEBUG_OPTS` (a local PowerShell variable never assigned in `mvn.ps1`). 
Debug JVM flags are silently dropped when launching via `mvnDebug.ps1`.
   
   ```suggestion
     $env:MAVEN_DEBUG_OPTS `
   ```



##########
apache-maven/src/bin/mvn.ps1:
##########
@@ -0,0 +1,158 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Startup Script
+
+Environment Variable Prerequisites
+
+  JAVA_HOME       (Optional) Points to a Java installation.
+  MAVEN_ARGS      (Optional) Arguments passed to Maven before CLI arguments.
+  MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+  MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+-----------------------------------------------------------------------------
+#>
+
+if (-not $env:MAVEN_SKIP_RC) {
+  if (Test-Path -Path $env:PROGRAMDATA\mavenrc.ps1 -PathType Leaf) { 
&$env:PROGRAMDATA"\mavenrc.ps1" $args }
+  if (Test-Path -Path $env:USERPROFILE\mavenrc.ps1 -PathType Leaf) { 
&$env:USERPROFILE"\mavenrc.ps1" $args }
+}
+
+if (-not (Test-path $env:JAVA_HOME)) {
+  try {
+    $JAVACMD = (get-command java).Source
+  } catch {
+    Write-Error -ErrorAction Stop -Message "The $env:JAVA_HOME has not been 
set, JAVA_HOME environment variable is not defined correctly, so Apache Maven 
cannot be started."
+  }
+}
+else {
+  $JAVACMD = $env:JAVA_HOME + "\bin\java.exe"

Review Comment:
   ⚠️ **Use `Join-Path` instead of string concatenation.** PR #878 already uses 
`Join-Path $env:JAVA_HOME bin java.exe`, which is idiomatic PowerShell.
   
   ```suggestion
     $JAVACMD = Join-Path $env:JAVA_HOME bin java.exe
   ```



##########
apache-maven/src/bin/mvn.ps1:
##########
@@ -0,0 +1,158 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Startup Script
+
+Environment Variable Prerequisites
+
+  JAVA_HOME       (Optional) Points to a Java installation.
+  MAVEN_ARGS      (Optional) Arguments passed to Maven before CLI arguments.
+  MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+  MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+-----------------------------------------------------------------------------
+#>
+
+if (-not $env:MAVEN_SKIP_RC) {
+  if (Test-Path -Path $env:PROGRAMDATA\mavenrc.ps1 -PathType Leaf) { 
&$env:PROGRAMDATA"\mavenrc.ps1" $args }
+  if (Test-Path -Path $env:USERPROFILE\mavenrc.ps1 -PathType Leaf) { 
&$env:USERPROFILE"\mavenrc.ps1" $args }
+}
+
+if (-not (Test-path $env:JAVA_HOME)) {
+  try {
+    $JAVACMD = (get-command java).Source
+  } catch {
+    Write-Error -ErrorAction Stop -Message "The $env:JAVA_HOME has not been 
set, JAVA_HOME environment variable is not defined correctly, so Apache Maven 
cannot be started."
+  }
+}
+else {
+  $JAVACMD = $env:JAVA_HOME + "\bin\java.exe"
+}
+
+if (-not (Test-Path $JAVACMD)) {
+  Write-Error -Message "The JAVA_HOME environment variable is not defined 
correctly, so Apache Maven cannot be started."
+  $ERROR_MESSAGE = "JAVA_HOME is set to " + $env:JAVA_HOME + ", but " + 
$JAVACMD + " does not exist."
+  Write-Error -ErrorAction Stop -Message $ERROR_MESSAGE
+}
+
+# check mvn home
+$MAVEN_HOME = (Get-Item $PSScriptRoot).Parent
+
+# check if maven command exists
+if (-not (Test-path "$MAVEN_HOME\bin\mvn.ps1")) {
+    Write-Error -Message "maven command (\bin\mvn.ps1) cannot be found" 
-ErrorAction Stop
+}
+# ==== END VALIDATION ====
+
+$CLASSWORLDS_CONF = "$MAVEN_HOME\bin\m2.conf"
+
+# Find the project basedir, i.e., the directory that contains the directory 
".mvn".
+# Fallback to current working directory if not found.
+
+$WDIR = Get-Location
+
+# Look for the --file switch and start the search for the .mvn directory from 
the specified
+# POM location, if supplied.
+
+$i = 0
+$file_flag_found = $false
+foreach ($arg in $args) {
+  if (($arg -ceq "-f") -or ($arg -ceq "--file")) {
+    $file_flag_found = $true
+    break
+  }
+  $i += 1
+}
+
+function IsNotRoot {
+  param (
+    [String] $path
+  )
+  $root_path_base_name = ((get-item $path).Root.BaseName
+  $path_base_name = ((get-item $path).BaseName
+
+  return $root_path_base_name -ne $path_base_name
+}
+
+function RetrieveContentsJvmConfig {
+  param (
+    [String] $path
+  )
+
+  $jvm_location = $path + "\.mvn\jvm.config"
+
+  if (Test-Path $jvm_location) {
+    return $env:MAVEN_OPTS + " " + -Join (Get-Content $jvm_location)
+  }
+  return $env:MAVEN_OPTS
+}
+
+$basedir = ""
+
+if ($file_flag_found) {
+  # we need to assess if the file exists
+  # and then search for the maven project base dir. 
+  $pom_file_reference = $args[$i + 1]
+
+  if (Test-Path $pom_file_reference) {
+    $basedir = (Get-Item $pom_file_reference).DirectoryName
+  }
+  else {
+    $pom_file_error = "POM file " + $pom_file_reference + " specified the 
-f/--file command-line argument does not exist"
+    Write-Error -Message $pom_file_error -ErrorAction Stop
+  }
+}
+else {
+  # if file flag is not found, then the pom.xml is relative to the working dir 
+  # and the jvm.config can be found in the maven project base dir. 
+
+  $basedir = $WDIR
+
+  while (IsNotRoot($WDIR.Path)) {
+    if (Test-Path "$WDIR\.mvn") {
+      $basedir = $WDIR
+      break
+    }
+
+    if ($WDIR) {
+      $WDIR = Split-Path $WDIR      
+    }
+    else {
+      break
+    }  
+  }
+}
+
+$MAVEN_OPTS = (RetrieveContentsJvmConfig $basedir)
+
+$LAUNCHER_JAR = Get-Item $MAVEN_HOME"\boot\plexus-classworlds*.jar"
+$LAUNCHER_CLASS = "org.codehaus.plexus.classworlds.launcher.Launcher"
+
+& $JAVACMD `
+  $MAVEN_OPTS `
+  $MAVEN_DEBUG_OPTS `
+  -classpath $LAUNCHER_JAR `
+  "-Dclassworlds.conf=$CLASSWORLDS_CONF" `
+  "-Dmaven.home=$MAVEN_HOME" `
+  "-Dlibrary.jansi.path=$MAVEN_HOME\lib\jansi-native" `
+  "-Dmaven.multiModuleProjectDirectory=$basedir" `
+  $LAUNCHER_CLASS `
+  $MAVEN_ARGS `
+  $args

Review Comment:
   ⚠️ **Missing exit code propagation.** The Maven process exit code is 
available in `$LASTEXITCODE` after the `& $JAVACMD` invocation, but it is not 
propagated to the caller. Any script or CI pipeline invoking `mvn.ps1` will 
receive exit code 0 even when Maven fails.
   
   ```suggestion
     $args
   
   exit $LASTEXITCODE
   ```



##########
apache-maven/src/bin/mvnDebug.ps1:
##########
@@ -0,0 +1,42 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Debug Script
+
+Environment Variable Prerequisites
+
+JAVA_HOME           (Optional) Points to a Java installation.
+MAVEN_OPTS          (Optional) Java runtime options used when Maven is 
executed.
+MAVEN_SKIP_RC       (Optional) Flag to disable loading of mavenrc files.
+MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is 
localhost:8000
+-----------------------------------------------------------------------------
+#>
+
+# set title
+$Host.UI.RawUI.WindowTitle = $MyInvocation.MyCommand
+
+if (-not $env:MAVEN_DEBUG_ADDRESS ) {
+  $env:MAVEN_DEBUG_ADDRESS = "8000"

Review Comment:
   ⚠️ **Debug address defaults to all interfaces.** Setting 
`MAVEN_DEBUG_ADDRESS = "8000"` (bare port, no hostname) causes the JVM debug 
agent to listen on all network interfaces on Java 9+, exposing the debug port 
on non-loopback interfaces. The header comment says the default is 
`localhost:8000` — the code disagrees. PR #878 correctly uses 
`"localhost:8000"`.
   
   ```suggestion
     $env:MAVEN_DEBUG_ADDRESS = "localhost:8000"
   ```



##########
apache-maven/src/bin/mvn.ps1:
##########
@@ -0,0 +1,158 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Startup Script
+
+Environment Variable Prerequisites
+
+  JAVA_HOME       (Optional) Points to a Java installation.
+  MAVEN_ARGS      (Optional) Arguments passed to Maven before CLI arguments.
+  MAVEN_OPTS      (Optional) Java runtime options used when Maven is executed.
+  MAVEN_SKIP_RC   (Optional) Flag to disable loading of mavenrc files.
+-----------------------------------------------------------------------------
+#>
+
+if (-not $env:MAVEN_SKIP_RC) {
+  if (Test-Path -Path $env:PROGRAMDATA\mavenrc.ps1 -PathType Leaf) { 
&$env:PROGRAMDATA"\mavenrc.ps1" $args }
+  if (Test-Path -Path $env:USERPROFILE\mavenrc.ps1 -PathType Leaf) { 
&$env:USERPROFILE"\mavenrc.ps1" $args }
+}
+
+if (-not (Test-path $env:JAVA_HOME)) {

Review Comment:
   ⚠️ **`Test-Path` on potentially null `$env:JAVA_HOME`.** When `JAVA_HOME` is 
not set, `$env:JAVA_HOME` is `$null`. On PowerShell 5.x, `Test-Path -Path 
$null` throws `ParameterBindingValidationException` instead of returning 
`$false`, bypassing the `Get-Command java` fallback. Guard with an explicit 
null/empty check:
   
   ```suggestion
   if (-not $env:JAVA_HOME -or -not (Test-Path $env:JAVA_HOME)) {
   ```



##########
apache-maven/src/bin/mvnDebug.ps1:
##########
@@ -0,0 +1,42 @@
+<#
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+
+-----------------------------------------------------------------------------
+Apache Maven Debug Script
+
+Environment Variable Prerequisites
+
+JAVA_HOME           (Optional) Points to a Java installation.
+MAVEN_OPTS          (Optional) Java runtime options used when Maven is 
executed.
+MAVEN_SKIP_RC       (Optional) Flag to disable loading of mavenrc files.
+MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is 
localhost:8000
+-----------------------------------------------------------------------------
+#>
+
+# set title
+$Host.UI.RawUI.WindowTitle = $MyInvocation.MyCommand
+
+if (-not $env:MAVEN_DEBUG_ADDRESS ) {
+  $env:MAVEN_DEBUG_ADDRESS = "8000"
+}
+
+$env:MAVEN_DEBUG_OPTS = "-Xdebug 
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=$env:MAVEN_DEBUG_ADDRESS"
+
+$mvnCmd = $PSScriptRoot + "\mvn.ps1"

Review Comment:
   💡 **Use `Join-Path` for path construction.** Consistent with the fix needed 
in `mvn.ps1` and already done in PR #878.
   
   ```suggestion
   $mvnCmd = Join-Path -Path $PSScriptRoot -ChildPath "mvn.ps1"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to