从java调用ant,ant终止后返回java [英] Invoke ant from java, then return to java after ant termination

查看:39
本文介绍了从java调用ant,ant终止后返回java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经从 java 调用了 ant 脚本.现在的问题是,在ant build终止后是否可以恢复java的执行?

so far i have invoked ant script from java. Now the question is, is it possible to resume java execution after the termination of the ant build?

我该怎么做?

推荐答案

org.apache.tools.ant.Mainmain()startAnt() 方法调用 exit() 方法,后者又调用 System.exit(code).

org.apache.tools.ant.Main's main() and startAnt() methods call the exit() method which in turn calls System.exit(code).

解决方案(假设您调用这些方法之一)是子类org.apache.tools.ant.Main 并覆盖exit() 方法

The solution (assuming you call one of those methods) is to sub-class org.apache.tools.ant.Main and override the exit() method

/**
 * This operation is expected to call {@link System#exit(int)}, which
 * is what the base version does.
 * However, it is possible to do something else.
 * @param exitCode code to exit with
 */
protected void exit(int exitCode) {
    System.exit(exitCode);
}

这篇关于从java调用ant,ant终止后返回java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆