diff --git a/WHATSNEW b/WHATSNEW index ccd1fe4c4..2b5f20c92 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -11,6 +11,8 @@ properties files and output them instead of Ant's properties. * will now resolve filters recursively. +* has a new attribute that allows you to specify a default value. + Changes from Ant 1.4.1 to Ant 1.5 ================================= diff --git a/src/main/org/apache/tools/ant/taskdefs/Input.java b/src/main/org/apache/tools/ant/taskdefs/Input.java index 7d3822618..c07d2da37 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Input.java +++ b/src/main/org/apache/tools/ant/taskdefs/Input.java @@ -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); } }