peterreilly 2005/04/21 02:49:55 Modified: . WHATSNEW docs/manual/CoreTasks macrodef.html src/etc/testcases/taskdefs macrodef.xml src/main/org/apache/tools/ant/taskdefs MacroDef.java MacroInstance.java src/testcases/org/apache/tools/ant/taskdefs MacroDefTest.java Log: add backtrace attribute to <macrodef> PR: 27219 Revision Changes Path 1.810 +2 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.809 retrieving revision 1.810 diff -u -r1.809 -r1.810 --- WHATSNEW 19 Apr 2005 22:30:38 -0000 1.809 +++ WHATSNEW 21 Apr 2005 09:49:55 -0000 1.810 @@ -181,6 +181,8 @@ * <exec> (and hence, <apply>) have an OsFamily attribute, which can restrict execution to a single OS family. +* added "backtrace" attribute to macrodef. Bugzilla report 27219. + Changes from Ant 1.6.2 to current Ant 1.6 CVS version ===================================================== 1.25 +11 -0 ant/docs/manual/CoreTasks/macrodef.html Index: macrodef.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/macrodef.html,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- macrodef.html 23 Mar 2005 18:48:59 -0000 1.24 +++ macrodef.html 21 Apr 2005 09:49:55 -0000 1.25 @@ -50,6 +50,17 @@ </td> <td valign="top" align="center">No</td> </tr> + <tr> + <td valign="top">backtrace</td> + <td valign="top"> + This controls the error traceback if they is an + error detected when running the macro. If this is + set to true, there will be an erro trackback, if false + there will not be one. The default value is true. + <em>Since ant 1.7</em>. + </td> + <td valign="top" align="center">No</td> + </tr> </table> <h3>Parameters specified as nested elements</h3> <h4>attribute</h4> 1.13 +16 -0 ant/src/etc/testcases/taskdefs/macrodef.xml Index: macrodef.xml =================================================================== RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/macrodef.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- macrodef.xml 27 May 2004 14:38:46 -0000 1.12 +++ macrodef.xml 21 Apr 2005 09:49:55 -0000 1.13 @@ -223,4 +223,20 @@ </target> + <target name="backtraceoff"> + <macrodef name="nobacktrace" backtrace="false"> + <sequential> + <fail>This is a failure</fail> + </sequential> + </macrodef> + <nobacktrace/> + </target> + <target name="backtraceon"> + <macrodef name="nobacktrace" backtrace="true"> + <sequential> + <fail>This is a failure</fail> + </sequential> + </macrodef> + <nobacktrace/> + </target> </project> 1.32 +23 -0 ant/src/main/org/apache/tools/ant/taskdefs/MacroDef.java Index: MacroDef.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/MacroDef.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- MacroDef.java 15 Mar 2005 13:35:28 -0000 1.31 +++ MacroDef.java 21 Apr 2005 09:49:55 -0000 1.32 @@ -42,6 +42,7 @@ public class MacroDef extends AntlibDefinition { private NestedSequential nestedSequential; private String name; + private boolean backTrace = true; private List attributes = new ArrayList(); private Map elements = new HashMap(); private String textName = null; @@ -93,6 +94,28 @@ } /** + * Set the backTrace attribute. + * + * @param backTrace if true and the macro instance generates has + * an error, a backtrace of the location within + * the macro and call to the macro will be outout. + * if false, only the location of the call to + * macro will be shown. Default is true. + * @since ant 1.7 + */ + public void setBackTrace(boolean backTrace) { + this.backTrace = backTrace; + } + + /** + * @return the backTrace attribute. + * @since ant 1.7 + */ + public boolean getBackTrace() { + return backTrace; + } + + /** * This is the sequential nested element of the macrodef. * * @return a sequential element to be configured. 1.34 +6 -2 ant/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java Index: MacroInstance.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- MacroInstance.java 14 Jan 2005 16:49:34 -0000 1.33 +++ MacroInstance.java 21 Apr 2005 09:49:55 -0000 1.34 @@ -380,8 +380,12 @@ try { c.perform(); } catch (BuildException ex) { - throw ProjectHelper.addLocationToBuildException( - ex, getLocation()); + if (macroDef.getBackTrace()) { + throw ProjectHelper.addLocationToBuildException( + ex, getLocation()); + } else { + throw new BuildException(ex.getMessage(), ex); + } } finally { presentElements = null; localAttributes = null; 1.18 +18 -0 ant/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java Index: MacroDefTest.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- MacroDefTest.java 27 May 2004 14:38:46 -0000 1.17 +++ MacroDefTest.java 21 Apr 2005 09:49:55 -0000 1.18 @@ -18,6 +18,7 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.BuildFileTest; +import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; @@ -128,5 +129,22 @@ "Only one element allowed when using implicit elements", "Only one element allowed when using implicit elements"); } + + public void testBackTraceOff() { + try { + executeTarget("backtraceoff"); + } catch (BuildException ex) { + if (ex.getMessage().indexOf("following error occurred") != -1) { + fail("error message contained backtrace - " + ex.getMessage()); + } + } + } + + public void testBackTrace() { + expectBuildExceptionContaining( + "backtraceon", + "Checking if a back trace is created", + "following error occurred"); + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]