what's the difference between AntCall and Ant tasks?

不羁的心 提交于 2019-12-19 16:10:11

问题


Is there any substantial difference between the AntCall task (described here) and the Ant task (described here), except for the fact that Ant task runs on a different build file?


回答1:


It really depends on what you mean by "substantial difference". The difference would be that one calls the other, so basically is the same thing but used in different contexts.

Here is a snippet from defaults.properties which defines the standard Ant tasks:

ant=org.apache.tools.ant.taskdefs.Ant
antcall=org.apache.tools.ant.taskdefs.CallTarget
...........

If you open up the source code of these tasks you will see that CallTarget contains an Ant object and delegates most of the work to it:

public class CallTarget extends Task {
    private Ant callee;
    ...........
    ...........
    /**
     * Delegate the work to the ant task instance, after setting it up.
     * @throws BuildException on validation failure or if the target didn't
     * execute.
     */
    public void execute() throws BuildException {
        if (callee == null) {
            init();
        }
        if (!targetSet) {
            throw new BuildException(
                "Attribute target or at least one nested target is required.",
                 getLocation());
        }
        callee.setAntfile(getProject().getProperty("ant.file"));
        callee.setInheritAll(inheritAll);
        callee.setInheritRefs(inheritRefs);
        callee.execute();
    }
    ..........
    ..........
}


来源:https://stackoverflow.com/questions/2756816/whats-the-difference-between-antcall-and-ant-tasks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!