DefaultLogger consoleLogger = new DefaultLogger();
ByteArrayOutputStream baop = new ByteArrayOutputStream();
//将控制台信息写入到字符数组中
System.setOut(new PrintStream(baop));p.init();
//ProjectHelper2 helper = (ProjectHelper2) ProjectHelper.getProjectHelper(); // 会与eclipse自身插件中的Ant起冲突
}
private void printSuccessMessage(ByteArrayOutputStream baop) {
String string;
try {
string = new String(baop.toByteArray(), "utf-8");
string += "恭喜您,编译成功!";
MessageBoxUtil.confirmWithAsync(string);
try {
baop.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
private void printErrorMsg(Project p, ByteArrayOutputStream baop, BuildException be) throws IllegalArgumentException {
String string;
try {
string = new String(baop.toByteArray(), "utf-8");
string += "抱歉,编译失败,请重新检查配置";
p.fireBuildFinished(be);
System.out.println(string);
throw new IllegalArgumentException(string);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}