Skip to content

Commit 7019b62

Browse files
committed
Fix Windows batch file pipe symbol escaping in JvmConfigParser
The JvmConfigParser.java was not properly escaping pipe symbols for Windows batch file processing. In Windows batch files, pipe symbols are command separators that are processed before quotes, so they need to be escaped with the caret (^) character. This change ensures that pipe symbols in jvm.config files are properly escaped as ^| when processed by the Windows batch file, preventing them from being interpreted as command separators. Also fixed compilation error in integration test by replacing constant reference with string literal for maven.consumer.pom.flatten property.
1 parent 44027a1 commit 7019b62

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

apache-maven/src/assembly/maven/bin/JvmConfigParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ public static void main(String[] args) {
7474
// Parse line into individual arguments (split on spaces, respecting quotes)
7575
List<String> parsed = parseArguments(line);
7676

77-
// Append each argument quoted
77+
// Append each argument quoted and escape pipe symbols for Windows batch
7878
for (String arg : parsed) {
7979
if (result.length() > 0) {
8080
result.append(' ');
8181
}
82-
result.append('"').append(arg).append('"');
82+
// Escape pipe symbols for Windows batch file processing
83+
String escapedArg = arg.replace("|", "^|");
84+
result.append('"').append(escapedArg).append('"');
8385
}
8486
});
8587

its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh11346DependencyManagementOverrideTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void testDependencyManagementOverride() throws Exception {
6262
Verifier verifier = newVerifier(testDir.getAbsolutePath());
6363
verifier.deleteArtifacts("org.apache.maven.its.mng.depman");
6464
// Test with dependency manager transitivity disabled instead of consumer POM flattening
65-
verifier.addCliArgument("-D" + Constants.MAVEN_CONSUMER_POM_FLATTEN + "=false");
65+
verifier.addCliArgument("-Dmaven.consumer.pom.flatten=false");
6666
verifier.addCliArgument("verify");
6767
verifier.execute();
6868
verifier.verifyErrorFreeLog();
@@ -94,7 +94,7 @@ public void testDependencyManagementOverrideNoTransitive() throws Exception {
9494
Verifier verifier = newVerifier(testDir.getAbsolutePath());
9595
verifier.deleteArtifacts("org.apache.maven.its.mng.depman");
9696
// Test with dependency manager transitivity disabled instead of consumer POM flattening
97-
verifier.addCliArgument("-D" + Constants.MAVEN_CONSUMER_POM_FLATTEN + "=false");
97+
verifier.addCliArgument("-Dmaven.consumer.pom.flatten=false");
9898
verifier.addCliArgument("-D" + Constants.MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY + "=false");
9999
verifier.addCliArgument("verify");
100100
verifier.execute();

0 commit comments

Comments
 (0)