Skip to content

Commit

Permalink
code restructuring for better readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbien committed Jan 9, 2022
1 parent d3314fb commit 9ccc307
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -44,13 +45,14 @@ public List<String> construct() {

// use mvnd if its the home of a daemon
String ex = Files.exists(Paths.get(mavenHome.getPath(), "bin", "mvnd")) ? "mvnd" : "mvn"; //NOI18N

//#164234
//if maven.bat file is in space containing path, we need to quote with simple quotes.
String quote = "\"";
List<String> toRet = new ArrayList<>();
List<String> command = new ArrayList<>();

if (Utilities.isWindows()) {

//#153101, since #228901 always on windows use cmd /c
command.add("cmd"); //NOI18N
command.add("/c"); //NOI18N

String version = MavenSettings.getCommandLineMavenVersion(mavenHome);
if (null == version) {
ex += ".bat"; // NOI18N
Expand All @@ -66,14 +68,15 @@ public List<String> construct() {
}
}
}
File bin = new File(mavenHome, "bin" + File.separator + ex);//NOI18N
toRet.add(quoteSpaces(bin.getAbsolutePath(), quote));

if (Utilities.isWindows()) { //#153101, since #228901 always on windows use cmd /c
toRet.add(0, "/c"); //NOI18N
toRet.add(0, "cmd"); //NOI18N
}
return toRet;
//#164234
//if maven.bat file is in space containing path, we need to quote with simple quotes.
String quote = "\"";

Path bin = Paths.get(mavenHome.getPath(), "bin", ex).toAbsolutePath();//NOI18N
command.add(quoteSpaces(bin.toString(), quote));

return command;
}

// we run the shell/bat script in the process, on windows we need to quote any spaces
Expand Down

0 comments on commit 9ccc307

Please sign in to comment.