git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@720862 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -565,6 +565,11 @@ Other changes: | |||||
| process proceed if an error occurs. | process proceed if an error occurs. | ||||
| Bugzilla Report 36260. | 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 | Changes from Ant 1.7.0 TO Ant 1.7.1 | ||||
| ============================================= | ============================================= | ||||
| @@ -247,6 +247,14 @@ element which is used to perform Entity and URI resolution.</p> | |||||
| <em>Since Ant 1.8.0</em>.</td> | <em>Since Ant 1.8.0</em>.</td> | ||||
| <td valign="top" align="center">No, default is true.</td> | <td valign="top" align="center">No, default is true.</td> | ||||
| </tr> | </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> | </table> | ||||
| <h3>Parameters specified as nested elements</h3> | <h3>Parameters specified as nested elements</h3> | ||||
| @@ -190,6 +190,14 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
| */ | */ | ||||
| private boolean failOnError = true; | 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. | * Creates a new XSLTProcess Task. | ||||
| */ | */ | ||||
| @@ -389,7 +397,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
| } | } | ||||
| } else { // only resource collections, there better be some | } else { // only resource collections, there better be some | ||||
| if (resources.size() == 0) { | if (resources.size() == 0) { | ||||
| handleError("no resources specified"); | |||||
| if (failOnNoResources) { | |||||
| handleError("no resources specified"); | |||||
| } | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -576,6 +586,15 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
| failOnError = b; | failOnError = b; | ||||
| } | } | ||||
| /** | |||||
| * 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 | * Load processor here instead of in setProcessor - this will be | ||||
| * called from within execute, so we have access to the latest | * called from within execute, so we have access to the latest | ||||
| @@ -91,7 +91,7 @@ undefined='<xsl:value-of select="$undefined"/>' | |||||
| </au:expectfailure> | </au:expectfailure> | ||||
| </target> | </target> | ||||
| <target name="testTransformationError"> | |||||
| <target name="testTransformationError" depends="setUp"> | |||||
| <au:expectfailure expectedmessage="Fatal error during transformation"> | <au:expectfailure expectedmessage="Fatal error during transformation"> | ||||
| <xslt in="${legacy.dir}/../input.stdin" | <xslt in="${legacy.dir}/../input.stdin" | ||||
| out="${output}/out.xml" | out="${output}/out.xml" | ||||
| @@ -100,7 +100,7 @@ undefined='<xsl:value-of select="$undefined"/>' | |||||
| </au:expectfailure> | </au:expectfailure> | ||||
| </target> | </target> | ||||
| <target name="testTransformationErrorNoFail"> | |||||
| <target name="testTransformationErrorNoFail" depends="setUp"> | |||||
| <xslt in="${legacy.dir}/../input.stdin" | <xslt in="${legacy.dir}/../input.stdin" | ||||
| out="${output}/out.xml" | out="${output}/out.xml" | ||||
| style="${legacy.dir}/printParams.xsl" | style="${legacy.dir}/printParams.xsl" | ||||
| @@ -108,7 +108,7 @@ undefined='<xsl:value-of select="$undefined"/>' | |||||
| <au:assertFileDoesntExist file="${output}/out.xml"/> | <au:assertFileDoesntExist file="${output}/out.xml"/> | ||||
| </target> | </target> | ||||
| <target name="testTransformationErrorNoFailOnTransformation"> | |||||
| <target name="testTransformationErrorNoFailOnTransformation" depends="setUp"> | |||||
| <xslt in="${legacy.dir}/../input.stdin" | <xslt in="${legacy.dir}/../input.stdin" | ||||
| out="${output}/out.xml" | out="${output}/out.xml" | ||||
| style="${legacy.dir}/printParams.xsl" | style="${legacy.dir}/printParams.xsl" | ||||
| @@ -116,4 +116,34 @@ undefined='<xsl:value-of select="$undefined"/>' | |||||
| <au:assertFileDoesntExist file="${output}/out.xml"/> | <au:assertFileDoesntExist file="${output}/out.xml"/> | ||||
| </target> | </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> | </project> | ||||