Browse Source

revert making ConditionBase a Task after discussion on dev@apache.org

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@451444 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
a045d5480c
4 changed files with 60 additions and 3 deletions
  1. +7
    -0
      src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
  2. +7
    -0
      src/main/org/apache/tools/ant/taskdefs/WaitFor.java
  3. +44
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
  4. +2
    -1
      src/tests/junit/org/apache/tools/ant/LocationTest.java

+ 7
- 0
src/main/org/apache/tools/ant/taskdefs/ConditionTask.java View File

@@ -43,6 +43,13 @@ public class ConditionTask extends ConditionBase {
private String value = "true"; private String value = "true";
private String alternative = null; private String alternative = null;


/**
* Constructor, names this task "condition".
*/
public ConditionTask() {
super("condition");
}

/** /**
* The name of the property to set. Required. * The name of the property to set. Required.
* @param p the name of the property * @param p the name of the property


+ 7
- 0
src/main/org/apache/tools/ant/taskdefs/WaitFor.java View File

@@ -59,6 +59,13 @@ public class WaitFor extends ConditionBase {
private long checkEveryMultiplier = 1L; private long checkEveryMultiplier = 1L;
private String timeoutProperty; private String timeoutProperty;


/**
* Constructor, names this task "waitfor".
*/
public WaitFor() {
super("waitfor");
}

/** /**
* Set the maximum length of time to wait. * Set the maximum length of time to wait.
* @param time a <code>long</code> value * @param time a <code>long</code> value


+ 44
- 2
src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java View File

@@ -23,7 +23,7 @@ import java.util.Vector;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.DynamicElement; import org.apache.tools.ant.DynamicElement;
import org.apache.tools.ant.ComponentHelper; import org.apache.tools.ant.ComponentHelper;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.taskdefs.Available; import org.apache.tools.ant.taskdefs.Available;
import org.apache.tools.ant.taskdefs.Checksum; import org.apache.tools.ant.taskdefs.Checksum;
import org.apache.tools.ant.taskdefs.UpToDate; import org.apache.tools.ant.taskdefs.UpToDate;
@@ -35,17 +35,38 @@ import org.apache.tools.ant.taskdefs.UpToDate;
* *
* @since Ant 1.4 * @since Ant 1.4
*/ */
public abstract class ConditionBase extends Task
public abstract class ConditionBase extends ProjectComponent
implements DynamicElement { implements DynamicElement {


private static final String CONDITION_ANTLIB private static final String CONDITION_ANTLIB
= "antlib:org.apache.tools.ant.types.conditions:"; = "antlib:org.apache.tools.ant.types.conditions:";


/**
* name of the component
*/
private String taskName="condition";

/** /**
* *
*/ */
private Vector conditions = new Vector(); private Vector conditions = new Vector();


/**
* Simple constructor.
*/
protected ConditionBase() {
taskName = "component";
}

/**
* Constructor that takes the name of the task in the task name.
* @param taskName
* @since Ant 1.7
*/
protected ConditionBase(String taskName) {
this.taskName = taskName;
}

/** /**
* Count the conditions. * Count the conditions.
* *
@@ -66,6 +87,27 @@ public abstract class ConditionBase extends Task
return conditions.elements(); return conditions.elements();
} }


/**
* Sets the name to use in logging messages.
*
* @param name The name to use in logging messages.
* Should not be <code>null</code>.
* @since Ant 1.7
*/
public void setTaskName(String name) {
this.taskName = name;
}

/**
* Returns the name to use in logging messages.
*
* @return the name to use in logging messages.
* @since Ant 1.7
*/
public String getTaskName() {
return taskName;
}

/** /**
* Add an &lt;available&gt; condition. * Add an &lt;available&gt; condition.
* @param a an available condition * @param a an available condition


+ 2
- 1
src/tests/junit/org/apache/tools/ant/LocationTest.java View File

@@ -46,7 +46,8 @@ public class LocationTest extends BuildFileTest {


public void testConditionTask() { public void testConditionTask() {
executeTarget("testConditionTask"); executeTarget("testConditionTask");
ConditionTask c = (ConditionTask) getProject().getReference("cond");
TaskAdapter ta = (TaskAdapter) getProject().getReference("cond");
ConditionTask c = (ConditionTask) ta.getProxy();
assertFalse(c.getLocation() == Location.UNKNOWN_LOCATION); assertFalse(c.getLocation() == Location.UNKNOWN_LOCATION);
assertFalse(c.getLocation().getLineNumber() == 0); assertFalse(c.getLocation().getLineNumber() == 0);
} }


Loading…
Cancel
Save