conor 01/08/02 04:42:55
Modified: src/main/org/apache/tools/ant ProjectHelper.java Target.java
Log:
Make if and unless attributes of <target> dynamically evaluated
PR: 2955
Revision Changes Path
1.59 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
Index: ProjectHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- ProjectHelper.java 2001/08/01 11:41:15 1.58
+++ ProjectHelper.java 2001/08/02 11:42:55 1.59
@@ -703,7 +703,7 @@
*
* @param value the string to be scanned for property references.
*/
- public static String replaceProperties(Project project, String value,
Hashtable keys )
+ public static String replaceProperties(Project project, String value,
Hashtable keys)
throws BuildException {
if (value == null) {
return null;
1.22 +11 -4 jakarta-ant/src/main/org/apache/tools/ant/Target.java
Index: Target.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Target.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Target.java 2001/07/26 10:13:23 1.21
+++ Target.java 2001/08/02 11:42:55 1.22
@@ -196,12 +196,19 @@
}
private boolean testIfCondition() {
- return "".equals(ifCondition)
- || project.getProperty(ifCondition) != null;
+ if ("".equals(ifCondition)) {
+ return true;
+ }
+
+ String test = ProjectHelper.replaceProperties(getProject(),
ifCondition, getProject().getProperties());
+ return project.getProperty(test) != null;
}
private boolean testUnlessCondition() {
- return "".equals(unlessCondition)
- || project.getProperty(unlessCondition) == null;
+ if ("".equals(unlessCondition)) {
+ return true;
+ }
+ String test = ProjectHelper.replaceProperties(getProject(),
unlessCondition, getProject().getProperties());
+ return project.getProperty(test) == null;
}
}