You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/11/26 15:24:02 UTC

svn commit: r720862 - in /ant/core/trunk: WHATSNEW docs/manual/CoreTasks/style.html src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java src/tests/antunit/taskdefs/xslt-test.xml

Author: bodewig
Date: Wed Nov 26 06:24:01 2008
New Revision: 720862

URL: http://svn.apache.org/viewvc?rev=720862&view=rev
Log:
Add a failOnNoResources attribute to xslt.  PR 46274.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTasks/style.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
    ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=720862&r1=720861&r2=720862&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Nov 26 06:24:01 2008
@@ -565,6 +565,11 @@
    process proceed if an error occurs.
    Bugzilla Report 36260.
 
+ * <xslt> has a new attribute failOnNoResources that can be used to 
+   make the build fail/continue if the collection of resources to
+   transform is empty.
+   Bugzilla Report 46274.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/docs/manual/CoreTasks/style.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/style.html?rev=720862&r1=720861&r2=720862&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/style.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/style.html Wed Nov 26 06:24:01 2008
@@ -247,6 +247,14 @@
     <em>Since Ant 1.8.0</em>.</td>
     <td valign="top" align="center">No, default is true.</td>
   </tr>
+  <tr>
+    <td valign="top">failOnNoResources</td>
+    <td valign="top">Whether the build should fail if the nested
+    resource collection is empty.  Note that this attribute has no
+    effect of <code>failOnError</code> is false.
+    <em>Since Ant 1.8.0</em>.</td>
+    <td valign="top" align="center">No, default is true.</td>
+  </tr>
 </table>
 <h3>Parameters specified as nested elements</h3>
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java?rev=720862&r1=720861&r2=720862&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java Wed Nov 26 06:24:01 2008
@@ -191,6 +191,14 @@
     private boolean failOnError = true;
 
     /**
+     * Whether the build should fail if the nested resource collection
+     * is empty.
+     *
+     * @since Ant 1.8.0
+     */
+    private boolean failOnNoResources = true;
+
+    /**
      * Creates a new XSLTProcess Task.
      */
     public XSLTProcess() {
@@ -389,7 +397,9 @@
                 }
             } else { // only resource collections, there better be some
                 if (resources.size() == 0) {
-                    handleError("no resources specified");
+                    if (failOnNoResources) {
+                        handleError("no resources specified");
+                    }
                     return;
                 }
             }
@@ -577,6 +587,15 @@
     }
 
     /**
+     * Whether the build should fail if the nested resource collection is empty.
+     *
+     * @since Ant 1.8.0
+     */
+    public void setFailOnNoResources(boolean b) {
+        failOnNoResources = b;
+    }
+
+    /**
      * Load processor here instead of in setProcessor - this will be
      * called from within execute, so we have access to the latest
      * classpath.

Modified: ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml?rev=720862&r1=720861&r2=720862&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml Wed Nov 26 06:24:01 2008
@@ -91,7 +91,7 @@
     </au:expectfailure>
   </target>
 
-  <target name="testTransformationError">
+  <target name="testTransformationError" depends="setUp">
     <au:expectfailure expectedmessage="Fatal error during transformation">
       <xslt in="${legacy.dir}/../input.stdin"
             out="${output}/out.xml"
@@ -100,7 +100,7 @@
     </au:expectfailure>
   </target>
 
-  <target name="testTransformationErrorNoFail">
+  <target name="testTransformationErrorNoFail" depends="setUp">
     <xslt in="${legacy.dir}/../input.stdin"
           out="${output}/out.xml"
           style="${legacy.dir}/printParams.xsl"
@@ -108,7 +108,7 @@
     <au:assertFileDoesntExist file="${output}/out.xml"/>
   </target>
 
-  <target name="testTransformationErrorNoFailOnTransformation">
+  <target name="testTransformationErrorNoFailOnTransformation" depends="setUp">
     <xslt in="${legacy.dir}/../input.stdin"
           out="${output}/out.xml"
           style="${legacy.dir}/printParams.xsl"
@@ -116,4 +116,34 @@
     <au:assertFileDoesntExist file="${output}/out.xml"/>
   </target>
 
+  <target name="testNoResources" depends="setUp">
+    <au:expectfailure expectedmessage="no resources specified">
+      <xslt destdir="${output}" style="${legacy.dir}/printParams.xsl"
+            useImplicitFileset="false">
+        <fileset dir=".">
+          <include name="I don't exist"/>
+        </fileset>
+      </xslt>
+    </au:expectfailure>
+  </target>
+
+  <target name="testNoResourcesNoFail" depends="setUp">
+    <xslt destdir="${output}" style="${legacy.dir}/printParams.xsl"
+          useImplicitFileset="false"
+          failOnNoResources="false">
+      <fileset dir=".">
+        <include name="I don't exist"/>
+      </fileset>
+    </xslt>
+  </target>
+
+  <target name="testNoResourcesNoError" depends="setUp">
+    <xslt destdir="${output}" style="${legacy.dir}/printParams.xsl"
+          useImplicitFileset="false"
+          failOnError="false">
+      <fileset dir=".">
+        <include name="I don't exist"/>
+      </fileset>
+    </xslt>
+  </target>
 </project>