Browse Source

Add default value to <input>.

Submitted by:	Scott Sanders <ssanders@nextance.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273043 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
b10ac6b22e
2 changed files with 20 additions and 1 deletions
  1. +2
    -0
      WHATSNEW
  2. +18
    -1
      src/main/org/apache/tools/ant/taskdefs/Input.java

+ 2
- 0
WHATSNEW View File

@@ -11,6 +11,8 @@ properties files and output them instead of Ant's properties.

* <filterset> will now resolve filters recursively.

* <input> has a new attribute that allows you to specify a default value.

Changes from Ant 1.4.1 to Ant 1.5
=================================



+ 18
- 1
src/main/org/apache/tools/ant/taskdefs/Input.java View File

@@ -77,6 +77,7 @@ public class Input extends Task {
private String validargs = null;
private String message = "";
private String addproperty = null;
private String defaultvalue = null;

/**
* Defines valid input parameters as comma separated strings. If set, input
@@ -109,6 +110,17 @@ public class Input extends Task {
this.message = message;
}

/**
* Defines the default value of the property to be created from input.
* Property value will be set to default if not input is received.
*
* @param defaultvalue Default value for the property if no input
* is received
*/
public void setDefaultvalue (String defaultvalue) {
this.defaultvalue = defaultvalue;
}

/**
* Set a multiline message.
*/
@@ -137,8 +149,13 @@ public class Input extends Task {

getProject().getInputHandler().handleInput(request);

String value = request.getInput();
if ((value == null || value.trim().length() == 0)
&& defaultvalue != null) {
value = defaultvalue;
}
if (addproperty != null) {
project.setNewProperty(addproperty, request.getInput());
project.setNewProperty(addproperty, value);
}
}



Loading…
Cancel
Save