This is an automated email from the ASF dual-hosted git repository.

sergeychugunov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 5657fc20bb6 IGNITE-26770 Implement escaping of space chars in mvn 
command path on Windows (#12438)
5657fc20bb6 is described below

commit 5657fc20bb61149a10abe5b6b967757c3001f398
Author: Sergey Chugunov <[email protected]>
AuthorDate: Tue Nov 18 11:54:38 2025 +0400

    IGNITE-26770 Implement escaping of space chars in mvn command path on 
Windows (#12438)
---
 .../testframework/util/MavenUtils.java             | 41 +++++++++++++-
 .../testframework/util/MavenUtilsTest.java         | 62 ++++++++++++++++++++++
 .../IgniteCompatibilityBasicTestSuite.java         |  2 +
 3 files changed, 103 insertions(+), 2 deletions(-)

diff --git 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
index aa3ef465b58..1c04fa8d262 100644
--- 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
+++ 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtils.java
@@ -165,7 +165,8 @@ public class MavenUtils {
             return F.transform(model.getRepositories(), 
RepositoryBase::getUrl);
         }
         finally {
-            Files.deleteIfExists(outPath);
+            if (!U.isWindows())
+                Files.deleteIfExists(outPath);
         }
     }
 
@@ -191,7 +192,7 @@ public class MavenUtils {
     }
 
     /**
-     * Executes given command in operation system.
+     * Executes given command in operating system.
      *
      * @param cmd Command to execute.
      * @return Output of result of executed command.
@@ -238,12 +239,48 @@ public class MavenUtils {
         }
     }
 
+    /**
+     * Adds escape characters to path elements that contain spaces.
+     *
+     * @param path Original path with unescaped elements.
+     * @return Path with escaped elements.
+     */
+    public static String escapeSpaceCharsInPath(String path) {
+        int startBSlashIdx = path.indexOf('\\');
+        int endBSlashIdx = path.indexOf('\\', startBSlashIdx + 1);
+
+        if (endBSlashIdx < 0)
+            return path;
+
+        StringBuilder res = new StringBuilder(path.substring(0, 
startBSlashIdx));
+
+        while (endBSlashIdx > 0) {
+            String substring = path.substring(startBSlashIdx + 1, 
endBSlashIdx);
+
+            if (substring.contains(" "))
+                res.append("\\\"").append(substring).append("\"");
+            else
+                res.append("\\").append(substring);
+
+            startBSlashIdx = endBSlashIdx;
+            endBSlashIdx = path.indexOf('\\', startBSlashIdx + 1);
+        }
+
+        res.append("\\")
+            .append(path.substring(startBSlashIdx + 1));
+
+        return res.toString();
+    }
+
     /**
      * @return Maven executable command.
      */
     private static String buildMvnCommand() {
         String mvnCmd = resolveMavenApplicationPath();
 
+        if (U.isWindows())
+            mvnCmd = escapeSpaceCharsInPath(mvnCmd);
+
         Path mvnSettingsFilePath = resolveMavenSettingsFilePath();
 
         if (Files.exists(mvnSettingsFilePath))
diff --git 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtilsTest.java
 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtilsTest.java
new file mode 100644
index 00000000000..770c1acd3a8
--- /dev/null
+++ 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/util/MavenUtilsTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.compatibility.testframework.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static 
org.apache.ignite.compatibility.testframework.util.MavenUtils.escapeSpaceCharsInPath;
+
+/**
+ * Test class for {@link MavenUtils}.
+ */
+public class MavenUtilsTest {
+    /** Remains the same. */
+    private static final String NO_NEED_TO_ESCAPE_PATH_0 = "C:\\maven\\mvn.bat 
clean install";
+
+    /** Remains the same. */
+    private static final String NO_NEED_TO_ESCAPE_PATH_1 = "C:\\mvn.bat clean 
install";
+
+    /** Space chars in the middle of the path require escaping. */
+    private static final String UNESCAPED_PATH_0 = "C:\\software\\Apache 
Software Foundation\\maven\\bin\\mvn.bat dependency:tree";
+
+    /** Path with space chars escaped. */
+    private static final String ESCAPED_PATH_0 = "C:\\software\\\"Apache 
Software Foundation\"\\maven\\bin\\mvn.bat dependency:tree";
+
+    /** Space chars in several elements of the path require escaping. */
+    private static final String UNESCAPED_PATH_1 = "C:\\Program Files\\Apache 
Software Foundation\\maven\\bin\\mvn.bat clean install";
+
+    /** Path with space chars escaped. */
+    private static final String ESCAPED_PATH_1 = "C:\\\"Program 
Files\"\\\"Apache Software Foundation\"\\maven\\bin\\mvn.bat clean install";
+
+    /** */
+    @Test
+    public void testPathsWithoutSpacesStayUnchanged() {
+        Assert.assertEquals(NO_NEED_TO_ESCAPE_PATH_0, 
escapeSpaceCharsInPath(NO_NEED_TO_ESCAPE_PATH_0));
+
+        Assert.assertEquals(NO_NEED_TO_ESCAPE_PATH_1, 
escapeSpaceCharsInPath(NO_NEED_TO_ESCAPE_PATH_1));
+    }
+
+    /** */
+    @Test
+    public void testPathsWithSpaceCharsEscaped() {
+        Assert.assertEquals(ESCAPED_PATH_0, 
escapeSpaceCharsInPath(UNESCAPED_PATH_0));
+
+        Assert.assertEquals(ESCAPED_PATH_1, 
escapeSpaceCharsInPath(UNESCAPED_PATH_1));
+    }
+}
diff --git 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
index a5e53ae55fa..d615559ef06 100644
--- 
a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
+++ 
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
@@ -30,6 +30,7 @@ import 
org.apache.ignite.compatibility.persistence.MigratingToWalV2SerializerWit
 import 
org.apache.ignite.compatibility.persistence.MoveBinaryMetadataCompatibility;
 import 
org.apache.ignite.compatibility.persistence.PersistenceBasicCompatibilityTest;
 import org.apache.ignite.compatibility.persistence.SnapshotCompatibilityTest;
+import org.apache.ignite.compatibility.testframework.util.MavenUtilsTest;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
@@ -38,6 +39,7 @@ import org.junit.runners.Suite;
  */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
+    MavenUtilsTest.class,
     PersistenceBasicCompatibilityTest.class,
     InlineJavaObjectCompatibilityTest.class,
     IndexTypesCompatibilityTest.class,

Reply via email to