Browse Source

add verbose attribute to <subant> task

PR: 33787
Obtained from: Craig Ryan, Frank Somers


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277799 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
03c4f14818
4 changed files with 50 additions and 3 deletions
  1. +2
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +18
    -3
      docs/manual/CoreTasks/subant.html
  4. +27
    -0
      src/main/org/apache/tools/ant/taskdefs/SubAnt.java

+ 2
- 0
CONTRIBUTORS View File

@@ -32,6 +32,7 @@ Conor MacNeill
Craeg Strong Craeg Strong
Craig Cottingham Craig Cottingham
Craig R. McClanahan Craig R. McClanahan
Craig Ryan
Curtis White Curtis White
Cyrille Morvan Cyrille Morvan
Dale Anson Dale Anson
@@ -63,6 +64,7 @@ Erik Langenbach
Erik Meade Erik Meade
Ernst de Haan Ernst de Haan
Frederic Lavigne Frederic Lavigne
Frank Somers
Gary S. Weaver Gary S. Weaver
Gautam Guliani Gautam Guliani
Gero Vermaas Gero Vermaas


+ 3
- 0
WHATSNEW View File

@@ -248,6 +248,9 @@ Other changes:


* Added isfileselected condition. * Added isfileselected condition.


* Added verbose="true|false" attribute to <subant>. When verbose is enabled,
the directory name is logged on entry and exit of the sub-build. Bugzilla 33787.

Fixed bugs: Fixed bugs:
----------- -----------




+ 18
- 3
docs/manual/CoreTasks/subant.html View File

@@ -128,7 +128,7 @@
<td bgcolor="#eeeeee" valign="top" align="left"> <td bgcolor="#eeeeee" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">String</font> <font color="#000000" size="-1" face="arial,helvetica,sanserif">String</font>
</td> </td>
<td bgcolor="#eeeeee" valign="top" align="left" rowspan="9">
<td bgcolor="#eeeeee" valign="top" align="left" rowspan="10">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">Optional</font> <font color="#000000" size="-1" face="arial,helvetica,sanserif">Optional</font>
</td> </td>
</tr> </tr>
@@ -229,6 +229,21 @@
</td> </td>
</tr> </tr>


<!-- Attribute -->
<tr>
<td bgcolor="#eeeeee" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">verbose</font>
</td>
<td bgcolor="#eeeeee" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Enable/ disable log messages showing when each sub-build path is entered/ exited.
The default value is false.</font>
</td>
<td bgcolor="#eeeeee" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">boolean</font>
</td>
</tr>



</table> </table>
</blockquote></td></tr> </blockquote></td></tr>
@@ -491,7 +506,7 @@
<tr> <tr>
<td> <td>
<div align="center"><font color="#525D76" size="-1"><em> <div align="center"><font color="#525D76" size="-1"><em>
Copyright &copy; 2000-2004, The Apache Software Foundation. All Rights Reserved.
Copyright &copy; 2000-2005, The Apache Software Foundation. All Rights Reserved.
</em></font></div> </em></font></div>
</td> </td>
</tr> </tr>
@@ -499,4 +514,4 @@
</table> </table>


</body> </body>
</html>
</html>

+ 27
- 0
src/main/org/apache/tools/ant/taskdefs/SubAnt.java View File

@@ -65,6 +65,7 @@ public class SubAnt
private String subTarget = null; private String subTarget = null;
private String antfile = "build.xml"; private String antfile = "build.xml";
private File genericantfile = null; private File genericantfile = null;
private boolean verbose = false;
private boolean inheritAll = false; private boolean inheritAll = false;
private boolean inheritRefs = false; private boolean inheritRefs = false;
private boolean failOnError = true; private boolean failOnError = true;
@@ -180,11 +181,16 @@ public class SubAnt
BuildException buildException = null; BuildException buildException = null;
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
File file = null; File file = null;
String subdirPath = null;
Throwable thrownException = null; Throwable thrownException = null;
try { try {
File directory = null; File directory = null;
file = new File(filenames[i]); file = new File(filenames[i]);
if (file.isDirectory()) { if (file.isDirectory()) {
if (verbose) {
subdirPath = file.getPath();
log("Entering directory: " + subdirPath + "\n", Project.MSG_INFO);
}
if (genericantfile != null) { if (genericantfile != null) {
directory = file; directory = file;
file = genericantfile; file = genericantfile;
@@ -193,13 +199,22 @@ public class SubAnt
} }
} }
execute(file, directory); execute(file, directory);
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
} catch (RuntimeException ex) { } catch (RuntimeException ex) {
if (!(getProject().isKeepGoingMode())) { if (!(getProject().isKeepGoingMode())) {
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
throw ex; // throw further throw ex; // throw further
} }
thrownException = ex; thrownException = ex;
} catch (Throwable ex) { } catch (Throwable ex) {
if (!(getProject().isKeepGoingMode())) { if (!(getProject().isKeepGoingMode())) {
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
throw new BuildException(ex); throw new BuildException(ex);
} }
thrownException = ex; thrownException = ex;
@@ -223,6 +238,9 @@ public class SubAnt
new BuildException(thrownException); new BuildException(thrownException);
} }
} }
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
} }
} }
// check if one of the builds failed in keep going mode // check if one of the builds failed in keep going mode
@@ -323,6 +341,15 @@ public class SubAnt
this.subTarget = target; this.subTarget = target;
} }


/**
* Enable/ disable verbose log messages showing when each sub-build path is entered/ exited.
* The default value is "false".
* @param on true to enable verbose mode, false otherwise (default).
*/
public void setVerbose(boolean on) {
this.verbose = on;
}

/** /**
* Corresponds to <code>&lt;ant&gt;</code>'s * Corresponds to <code>&lt;ant&gt;</code>'s
* <code>output</code> attribute. * <code>output</code> attribute.


Loading…
Cancel
Save