-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformLauncher.java
More file actions
29 lines (26 loc) · 1020 Bytes
/
PlatformLauncher.java
File metadata and controls
29 lines (26 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.io.*;
import java.util.*;
public class PlatformLauncher {
public static void main(String[] args) throws Exception {
boolean isWindows = System.getProperty("os.name").contains("Windows");
List<String> finalArgs = new ArrayList<>();
if (isWindows) {
finalArgs.add("powershell");
finalArgs.add("-file");
finalArgs.add(args[0] + ".ps1");
} else {
finalArgs.add("sh");
finalArgs.add(args[0] + ".sh");
}
for (int i = 1; i < args.length; i++) {
finalArgs.add(args[i]);
}
Process proc = new ProcessBuilder(finalArgs).redirectErrorStream(true)
.directory(new File(System.getProperty("user.dir"))).start();
BufferedReader output = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while ((line = output.readLine()) != null)
System.out.println(line);
System.exit(proc.waitFor());
}
}