@@ -192,40 +192,7 @@ private static void downloadArtifact(String artifact) throws Exception {
192192 }
193193
194194 /**
195- * Adds escape characters to path elements that contain spaces.
196- *
197- * @param path Original path with unescaped elements.
198- * @return Path with escaped elements.
199- */
200- public static String escapeSpaceCharsInPath (String path ) {
201- int startBSlashIdx = path .indexOf ('\\' );
202- int endBSlashIdx = path .indexOf ('\\' , startBSlashIdx + 1 );
203-
204- if (endBSlashIdx < 0 )
205- return path ;
206-
207- StringBuilder res = new StringBuilder (path .substring (0 , startBSlashIdx ));
208-
209- while (endBSlashIdx > 0 ) {
210- String substring = path .substring (startBSlashIdx + 1 , endBSlashIdx );
211-
212- if (substring .contains (" " ))
213- res .append ("\\ \" " ).append (substring ).append ("\" " );
214- else
215- res .append ("\\ " ).append (substring );
216-
217- startBSlashIdx = endBSlashIdx ;
218- endBSlashIdx = path .indexOf ('\\' , startBSlashIdx + 1 );
219- }
220-
221- res .append ("\\ " )
222- .append (path .substring (startBSlashIdx + 1 ));
223-
224- return res .toString ();
225- }
226-
227- /**
228- * Executes given command in operation system.
195+ * Executes given command in operating system.
229196 *
230197 * @param cmd Command to execute.
231198 * @return Output of result of executed command.
@@ -236,7 +203,7 @@ private static String exec(String cmd) throws Exception {
236203 pb .redirectErrorStream (true );
237204
238205 pb .command (U .isWindows () ?
239- new String [] {"cmd" , "/c" , escapeSpaceCharsInPath ( cmd ) } :
206+ new String [] {"cmd" , "/c" , cmd } :
240207 new String [] {"/bin/bash" , "-c" , cmd });
241208
242209 final Process p = pb .start ();
@@ -272,12 +239,48 @@ private static String exec(String cmd) throws Exception {
272239 }
273240 }
274241
242+ /**
243+ * Adds escape characters to path elements that contain spaces.
244+ *
245+ * @param path Original path with unescaped elements.
246+ * @return Path with escaped elements.
247+ */
248+ public static String escapeSpaceCharsInPath (String path ) {
249+ int startBSlashIdx = path .indexOf ('\\' );
250+ int endBSlashIdx = path .indexOf ('\\' , startBSlashIdx + 1 );
251+
252+ if (endBSlashIdx < 0 )
253+ return path ;
254+
255+ StringBuilder res = new StringBuilder (path .substring (0 , startBSlashIdx ));
256+
257+ while (endBSlashIdx > 0 ) {
258+ String substring = path .substring (startBSlashIdx + 1 , endBSlashIdx );
259+
260+ if (substring .contains (" " ))
261+ res .append ("\\ \" " ).append (substring ).append ("\" " );
262+ else
263+ res .append ("\\ " ).append (substring );
264+
265+ startBSlashIdx = endBSlashIdx ;
266+ endBSlashIdx = path .indexOf ('\\' , startBSlashIdx + 1 );
267+ }
268+
269+ res .append ("\\ " )
270+ .append (path .substring (startBSlashIdx + 1 ));
271+
272+ return res .toString ();
273+ }
274+
275275 /**
276276 * @return Maven executable command.
277277 */
278278 private static String buildMvnCommand () {
279279 String mvnCmd = resolveMavenApplicationPath ();
280280
281+ if (U .isWindows ())
282+ mvnCmd = escapeSpaceCharsInPath (mvnCmd );
283+
281284 Path mvnSettingsFilePath = resolveMavenSettingsFilePath ();
282285
283286 if (Files .exists (mvnSettingsFilePath ))
0 commit comments