Index: jakarta-ant/src/main/org/apache/tools/ant/Target.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Target.java,v
retrieving revision 1.17
diff -r1.17 Target.java
150,166c150,176
< try {
< project.fireTaskStarted(task);
< task.maybeConfigure();
< task.execute();
< project.fireTaskFinished(task, null);
< }
< catch(RuntimeException exc) {
< if (exc instanceof BuildException) {
< BuildException be = (BuildException) exc;
< if (be.getLocation() ==
Location.UNKNOWN_LOCATION) {
< be.setLocation(task.getLocation());
< }
< }
< project.fireTaskFinished(task, exc);
< throw exc;
< }
< }
---
> try {
> project.fireTaskStarted(task);
> task.maybeConfigure();
>
> if (task.testIfCondition() && task.testUnlessCondition()) {
> task.execute();
> } else if (!task.testIfCondition()) {
> project.log(this, "Task skipped because property '" + task.getIf()
+ "' not set.",
> Project.MSG_VERBOSE);
> } else {
> project.log(this, "Task skipped because property '" +
task.getUnless() + "' set.",
> Project.MSG_VERBOSE);
> }
>
> project.fireTaskFinished(task, null);
> }
> catch(RuntimeException exc) {
> if (exc instanceof BuildException) {
> BuildException be = (BuildException) exc;
> if (be.getLocation() == Location.UNKNOWN_LOCATION) {
> be.setLocation(task.getLocation());
> }
> }
> project.fireTaskFinished(task, exc);
> throw exc;
> }
> }
168c178
< project.log(this, "Skipped because property '" +
this.ifCondition + "' not set.",
---
> project.log(this, "Target skipped because property '" +
this.ifCondition + "' not set.",
171c181
< project.log(this, "Skipped because property '" +
this.unlessCondition + "' set.",
---
> project.log(this, "Target skipped because property '" +
this.unlessCondition + "' set.",
Index: jakarta-ant/src/main/org/apache/tools/ant/Task.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/Task.java,v
retrieving revision 1.17
diff -r1.17 Task.java
71a72,73
> protected String ifCondition = "";
> protected String unlessCondition = "";
169a172,187
> public void setIf( String property ) {
> ifCondition=(property == null) ? "" : property;
> }
>
> public String getIf() {
> return ifCondition;
> }
>
> public void setUnless( String property ) {
> unlessCondition=(property == null) ? "" : property;
> }
>
> public String getUnless() {
> return unlessCondition;
> }
>
222a241,251
>
> public boolean testIfCondition() {
> return "".equals(ifCondition)
> || project.getProperty(ifCondition) != null;
> }
>
> public boolean testUnlessCondition() {
> return "".equals(unlessCondition)
> || project.getProperty(unlessCondition) == null;
> }
>