From def52dd8afb6d219d555ab5a2b81d68930c1fb27 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Wed, 26 Nov 2008 14:24:01 +0000
Subject: [PATCH] Add a failOnNoResources attribute to xslt. PR 46274.
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@720862 13f79535-47bb-0310-9956-ffa450edef68
---
WHATSNEW | 5 +++
docs/manual/CoreTasks/style.html | 8 +++++
.../tools/ant/taskdefs/XSLTProcess.java | 21 ++++++++++-
src/tests/antunit/taskdefs/xslt-test.xml | 36 +++++++++++++++++--
4 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/WHATSNEW b/WHATSNEW
index ecd5a136c..d528bbd33 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -565,6 +565,11 @@ Other changes:
process proceed if an error occurs.
Bugzilla Report 36260.
+ * 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
=============================================
diff --git a/docs/manual/CoreTasks/style.html b/docs/manual/CoreTasks/style.html
index af43db68d..04ee7db3b 100644
--- a/docs/manual/CoreTasks/style.html
+++ b/docs/manual/CoreTasks/style.html
@@ -247,6 +247,14 @@ element which is used to perform Entity and URI resolution.
Since Ant 1.8.0.
No, default is true. |
+
+ failOnNoResources |
+ Whether the build should fail if the nested
+ resource collection is empty. Note that this attribute has no
+ effect of failOnError is false.
+ Since Ant 1.8.0. |
+ No, default is true. |
+
Parameters specified as nested elements
diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
index 7c69b3295..f2d6b2372 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
@@ -190,6 +190,14 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
*/
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.
*/
@@ -389,7 +397,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
}
} else { // only resource collections, there better be some
if (resources.size() == 0) {
- handleError("no resources specified");
+ if (failOnNoResources) {
+ handleError("no resources specified");
+ }
return;
}
}
@@ -576,6 +586,15 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
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
* called from within execute, so we have access to the latest
diff --git a/src/tests/antunit/taskdefs/xslt-test.xml b/src/tests/antunit/taskdefs/xslt-test.xml
index f4b761a82..2bb0e9877 100644
--- a/src/tests/antunit/taskdefs/xslt-test.xml
+++ b/src/tests/antunit/taskdefs/xslt-test.xml
@@ -91,7 +91,7 @@ undefined=''
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+