除了AntCall任务在不同的构建文件上运行之外,Ant任务(描述为here)和Ant任务(描述为here)之间有什么本质上的区别吗?
发布于 2010-05-03 19:43:28
这真的取决于你所说的“实质性差异”是什么意思。不同之处在于一个调用另一个,所以基本上是相同的东西,但在不同的上下文中使用。
下面是来自defaults.properties的一段代码,它定义了标准的Ant任务:
ant=org.apache.tools.ant.taskdefs.Ant
antcall=org.apache.tools.ant.taskdefs.CallTarget
...........如果您打开这些任务的源代码,您将看到CallTarget包含一个Ant对象,并将大部分工作委托给它:
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
复制相似问题