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
|
PrintStream stdout = System.out;
PrintStream stderr = System.err;
try {
Javac compile = new Javac();
compile.init();
compile.setVerbose(true);
compile.setProject(mainProject);
compile.setSrcdir(values.src_dir_path);
compile.setDestdir(new File(values.property_class_dir));
compile.createInclude().setName("com/");
compile.setDebug(true);
compile.setDeprecation(true);
compile.setOptimize(true);
compile.setClasspath(values.project_class_path);
compile.setMemoryMaximumSize("1024m");
compile.setFork(true);
compile.setOptimize(true);
// preserve old stdout/stderr streams in case they might be useful
StringBuffer out = new StringBuffer();
System.setOut(new PrintStream(new StringBufferOutputStream(out)));
System.setErr(new PrintStream(new StringBufferOutputStream(out)));
compile.execute();
return out.toString();
}finally {
System.setOut(stdout);
System.setErr(stderr);
} |