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


##########
apache-maven/src/assembly/maven/bin/mvn.cmd:
##########
@@ -379,26 +381,65 @@ if "%~1"=="--debug" (
 )
 exit /b 0
 
+:readClappMainClass
+if not exist "%~1" exit /b 0
+for /f "usebackq tokens=1,* delims==" %%a in ("%~1") do (
+    if "%%a"=="mainClass" set "MAVEN_CLAPP_MAIN_CLASS=%%b"
+)
+exit /b 0
+
 :processArgs
 if "%~1"=="" exit /b 0
+set "_PROC_ARG=%~1"
+if "%_PROC_ARG%"=="--clapp" (
+    if "%~2"=="" (
+        echo Error: --clapp requires a tool name argument ^(e.g. --clapp 
mvnfoo^) >&2
+        goto error
+    )
+    set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenClappCling"
+    set "MAVEN_CLAPP_NAME=%~2"
+    shift
+    shift
+    goto processArgs
+)
+if "%_PROC_ARG:~0,8%"=="--clapp=" (
+    set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenClappCling"
+    set "MAVEN_CLAPP_NAME=%_PROC_ARG:~8%"
+    if "%MAVEN_CLAPP_NAME%"=="" (

Review Comment:
   💡 **Nit — CMD delayed expansion pitfall.** Inside a `( )` block, `%VAR%` is 
expanded at parse time, not execution time. Line 407 sets `MAVEN_CLAPP_NAME`, 
but line 408 checks `%MAVEN_CLAPP_NAME%` — which still holds the *old* value 
from before the block started.
   
   In practice this works on first invocation (old value is also empty), but 
the pattern is fragile. Use the already-parsed `%_PROC_ARG:~8%` directly:
   
   ```suggestion
       set "MAVEN_CLAPP_NAME=%_PROC_ARG:~8%"
       if "%_PROC_ARG:~8%"=="" (
   ```



-- 
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