gnodet-bot commented on code in PR #878:
URL: https://github.com/apache/maven/pull/878#discussion_r4079332103
##########
apache-maven/src/assembly/component.xml:
##########
@@ -114,6 +115,19 @@ under the License.
<lineEnding>dos</lineEnding>
<filtered>true</filtered>
</file>
+ <file>
+ <sources>
+ <source>src/assembly/shared/validate.ps1</source>
Review Comment:
⛔ **Architecture mismatch — this won't work on master.**
The `<file><sources>` concatenation pattern was removed from `component.xml`
in Maven 4.x. Current master's descriptor has zero `<file>` elements. The
assembled `mvn.ps1` will not be generated.
The correct approach is a self-contained `mvn.ps1` placed directly in
`apache-maven/src/assembly/maven/bin/` — the `<fileSet>` hunk in this same PR
(adding `*.ps1` to the existing `bin/` fileSet) is the right mechanism. The
`<file><sources>` block must be removed entirely.
##########
apache-maven/src/assembly/shared/run.ps1:
##########
@@ -0,0 +1,13 @@
+& $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 `
+ $env:MAVEN_ARGS `
Review Comment:
⚠️ **`$env:MAVEN_ARGS` scope inconsistency.**
`$env:MAVEN_ARGS` is an environment variable (persistent, inherited by child
processes), while `$MAVEN_OPTS`, `$MAVEN_DEBUG_OPTS`, `$LAUNCHER_JAR` etc. are
local script variables. This is inconsistent: if a user sets `$MAVEN_ARGS` as a
local variable in their session, it won't be picked up here.
Decide on one scope. `mvn.cmd` uses `%MAVEN_ARGS%` as an environment
variable — using `$env:MAVEN_ARGS` here is the correct parity choice, but it
should be declared explicitly (matching `validate.ps1`'s header comment) and
the other MAVEN_* variables that are currently local should be evaluated for
consistency.
##########
apache-maven/src/assembly/shared/init.ps1:
##########
@@ -0,0 +1,83 @@
+# ==== 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:
⛔ **PowerShell syntax error — unbalanced parentheses — script will NOT
parse.**
Both lines open two `((` but close only one `)`. This causes a parse-time
error before the script runs.
```suggestion
$root_path_base_name = (get-item $path).Root.BaseName
$path_base_name = (get-item $path).BaseName
```
##########
apache-maven/src/assembly/shared/run.ps1:
##########
@@ -0,0 +1,13 @@
+& $JAVACMD `
Review Comment:
⛔ **Missing `--enable-native-access=ALL-UNNAMED`.**
This JVM flag is required for JLine terminal support on Java 17+ and is
always passed by `mvn.cmd`:
```suggestion
& $JAVACMD `
--enable-native-access=ALL-UNNAMED `
```
Without it, JLine's native terminal detection fails and Maven 4.x renders
degraded console output (no colors, no progress bars) on PowerShell.
##########
apache-maven/src/assembly/maven/bin/mvnDebug.ps1:
##########
@@ -0,0 +1,43 @@
+<#
+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 = "localhost:8000"
+}
+
+$env:MAVEN_DEBUG_OPTS = "-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=$env:MAVEN_DEBUG_ADDRESS"
+
+$mvnCmd = join-path -Path $PSScriptRoot -ChildPath "mvn.ps1"
+
+&$mvnCmd $args
Review Comment:
⛔ **Exit code not propagated.**
Same issue as `run.ps1` — `mvnDebug.ps1` exits with code 0 even when the
Maven build fails.
```suggestion
&$mvnCmd $args
exit $LASTEXITCODE
```
##########
apache-maven/src/assembly/shared/init.ps1:
##########
@@ -0,0 +1,83 @@
+# ==== 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_config = $path + "\.mvn\jvm.config"
+
+ if (Test-Path $jvm_config) {
+ return $env:MAVEN_OPTS + " " + -Join (Get-Content $jvm_config)
Review Comment:
⚠️ **Leading-space bug when `$env:MAVEN_OPTS` is empty.**
`$env:MAVEN_OPTS + " " + -Join (Get-Content $jvm_config)` produces a leading
space (` -Xmx512m`) when `$env:MAVEN_OPTS` is unset/empty. Some JVM
implementations reject arguments with leading whitespace.
Use conditional concatenation or `@()` + `-join` pattern:
```suggestion
$opts = @()
if ($env:MAVEN_OPTS) { $opts += $env:MAVEN_OPTS }
$opts += (Get-Content $jvm_config)
return $opts -join ' '
```
##########
apache-maven/src/assembly/shared/run.ps1:
##########
@@ -0,0 +1,13 @@
+& $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 `
+ $env:MAVEN_ARGS `
+ $args
+
Review Comment:
⛔ **Exit code not propagated — CI cannot detect build failures.**
After the Java invocation, `$LASTEXITCODE` must be forwarded. Without it,
`mvn.ps1` always exits 0 regardless of whether the Maven build succeeded or
failed.
```suggestion
$args
exit $LASTEXITCODE
```
##########
apache-maven/src/assembly/shared/run.ps1:
##########
@@ -0,0 +1,13 @@
+& $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" `
Review Comment:
⛔ **Obsolete library path — Jansi is gone in Maven 4.x.**
Master migrated from Jansi to JLine native terminal support. The native
library path should be:
```suggestion
"-Dlibrary.jline.path=$MAVEN_HOME\lib\jline-native" `
```
The `jansi-native` directory no longer ships in the Maven 4.x distribution.
--
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]