forked from Peergos/web-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompileSubmodule.java
33 lines (29 loc) · 1.02 KB
/
CompileSubmodule.java
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
30
31
32
33
import java.io.*;
import java.net.*;
import java.nio.file.*;
import java.util.*;
import java.util.zip.*;
/** Compile submodule into Jar and JS
*/
public class CompileSubmodule {
public static void main(String[] a) throws Exception {
String dir = a[0];
if (isWindows()) {
runCommand(dir, "cmd", "/c", "ant", "dist");
runCommand(dir, "cmd", "/c", "ant", "gwtc");
} else {
runCommand(dir, "ant", "dist");
runCommand(dir, "ant", "gwtc");
}
}
public static int runCommand(String dir, String... command) throws Exception {
System.out.println(Arrays.asList(command));
ProcessBuilder pb = new ProcessBuilder(command).directory(new File(dir));
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
return pb.start().waitFor();
}
public static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().startsWith("windows");
}
}