Posted on 2008-10-27 17:52
沙漠中的鱼 阅读(201)
评论(0) 编辑 收藏 所属分类:
Java
http://www.ibm.com/developerworks/cn/websphere/library/techarticles/0502_gawor/0502_gawor.html
File buildFile = new File("build.xml");
Project p = new Project();
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.addBuildListener(consoleLogger);
try {
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
p.fireBuildFinished(null);
} catch (BuildException e) {
p.fireBuildFinished(e);
}