Hi,
I have a project which consist of many modules, where often each module
have similar build files with similar target names, and many consist of
further sub-modules, with their own build files.
When I build the entire project, ant just prints out the target names, but
gives no indication as to which build file the target it is executing is
located. As a result, the output from a build consists of a long list of
target names.
The simple patch attached changes the <ant> task so that before calling a
target in another Project, it does a log() to indicate which target and
buildfile it is about to call, and the number of <ant> nesting levels it
is currently at. It also does a log() when the target called has
completed.
This is similar logging as to what GNU make does when it calls make
recursively.
For large builds, I find this extremely useful as it tells me what
buildfile is currently being called. This also helps identifying build
problems quicker, as the calling history is there in the output. It may
also quickly show build file dependency problems too, as it is easier to
understand what buildfile is being called from where.
Anyway, its a very minor patch, and adds little real output. What do
people think? I've found it to provide useful info. Happy to be told
otherwise though! :)
Cheers,
David
diff -u -r /home/sits/ant.orig/jakarta-ant-1.4/src/main/org/apache/tools/ant/Project.java ./src/main/org/apache/tools/ant/Project.java
--- /home/sits/ant.orig/jakarta-ant-1.4/src/main/org/apache/tools/ant/Project.java Mon Oct 15 23:35:54 2001
+++ ./src/main/org/apache/tools/ant/Project.java Mon Oct 15 23:35:47 2001
@@ -112,6 +112,8 @@
private FilterSetCollection globalFilters = new FilterSetCollection(globalFilterSet);
private File baseDir;
+ private int callDepth = 0;
+
private Vector listeners = new Vector();
/** The Ant core classloader - may be null if using system loader */
@@ -224,6 +226,14 @@
public ClassLoader getCoreLoader() {
return coreLoader;
+ }
+
+ public void setCallDepth(int callDepth) {
+ this.callDepth = callDepth;
+ }
+
+ public int getCallDepth() {
+ return callDepth;
}
public void addBuildListener(BuildListener listener) {
diff -u -r /home/sits/ant.orig/jakarta-ant-1.4/src/main/org/apache/tools/ant/taskdefs/Ant.java ./src/main/org/apache/tools/ant/taskdefs/Ant.java
--- /home/sits/ant.orig/jakarta-ant-1.4/src/main/org/apache/tools/ant/taskdefs/Ant.java Mon Oct 15 23:35:53 2001
+++ ./src/main/org/apache/tools/ant/taskdefs/Ant.java Mon Oct 15 23:35:46 2001
@@ -253,7 +253,14 @@
throw new BuildException("ant task calling its own parent target");
}
+ int callDepth = project.getCallDepth() + 1;
+ p1.setCallDepth(callDepth);
+
+ log("[" + callDepth + "] Calling target " + target + " in " + antFile);
+
p1.executeTarget(target);
+
+ log("[" + callDepth + "] Completed target " + target + " in " + antFile);
} finally {
// help the gc
p1 = null;