Browse Source

Make if and unless attributes of <target> dynamically evaluated

PR:	2955


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269437 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
f97f71d5d1
2 changed files with 12 additions and 5 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/ProjectHelper.java
  2. +11
    -4
      src/main/org/apache/tools/ant/Target.java

+ 1
- 1
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -703,7 +703,7 @@ public class ProjectHelper {
*
* @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;


+ 11
- 4
src/main/org/apache/tools/ant/Target.java View File

@@ -196,12 +196,19 @@ public class Target implements TaskContainer {
}

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;
}
}

Loading…
Cancel
Save