Browse Source

remove exit ability from <input>

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270129 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
1318b84a90
4 changed files with 11 additions and 93 deletions
  1. +9
    -21
      docs/manual/CoreTasks/input.html
  2. +0
    -19
      src/etc/testcases/taskdefs/input.xml
  3. +2
    -37
      src/main/org/apache/tools/ant/taskdefs/Input.java
  4. +0
    -16
      src/testcases/org/apache/tools/ant/taskdefs/InputTest.java

+ 9
- 21
docs/manual/CoreTasks/input.html View File

@@ -18,9 +18,6 @@ or as character data nested into the element.</p>
<p>Optinonally a set of valid imput arguments can be defined via the validargs
attribute. Input task will require the user to reenter values until the entered
value matches one of the predefined.</p>
<p>Optionally a set of exit arguments can be defined via the exitargs attribute.
Input task will throw a BuildException with a customisable exit message if the
entered value matches one of the predefined.</p>
<p>Optionally a property can be created from the value entered by the user. This
property can then be used during the following build run. Input behaves according
to <a href="property.html">property task</a> which means that existing properties
@@ -37,11 +34,6 @@ cannot be overriden.</p>
<td valign="top">the Message which gets displayed to the user during the build run.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">exitmessage</td>
<td valign="top">the exit message which gets displayed when exiting the build run.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">validargs</td>
<td valign="top">comma separated String containing valid input arguments. If set,
@@ -51,15 +43,6 @@ cannot be overriden.</p>
be accepted you will need to define both arguments within validargs.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">exitargs</td>
<td valign="top">comma separated String containing exit arguments. If set,
input task will throw a BuildException with a customisable exit message if the
entered value matches to one of the predefined. Exitargs are compared case
sensitive. If you want 'x' and 'X' to end the build run you will need to define
both arguments within exitargs.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">addproperty</td>
<td valign="top">the name of a property to be created from input. Behaviour is equal
@@ -79,12 +62,17 @@ the build run until return key is pressed.</p>
/&gt;</pre>
<p>Will display the message &quot;Press Return key to continue...&quot; and pause
the build run until return key is pressed.</p>
<pre> &lt;input
<pre>
&lt;input
message=&quot;All data is going to be deleted from DB continue (y/n)?&quot;
validargs=&quot;y,n&quot;
exitargs=&quot;n&quot;
exitmessage=&quot;Build abborted by user.&quot;
/&gt;</pre>
addproperty=&quot;do.delete&quot;
/&gt;
&lt;condition propert=&quot;do.abort&quot;&gt;
&lt;equals arg1=&quot;n&quot; arg2=&quot;${do.delete}&quot; /&gt;
&lt;/condition&gt;
&lt;fail if=&quot;do.abort&quot;&gt;Build abborted by user.&lt;/fail&gt;
</pre>
<p>Will display the message &quot;All data is going to be deleted from DB continue
(y/n)?&quot; and require 'y+retrun key' to continue build or 'n+return key'
to exit build with following message &quot;Build abborted by user.&quot;.</p>


+ 0
- 19
src/etc/testcases/taskdefs/input.xml View File

@@ -16,15 +16,6 @@
<input testinput="test"
message="All data is going to be deleted from DB continue (y/n)?"
validargs="y,n"
exitargs="n"
/>
</target>

<target name="test4">
<input testinput="n"
message="All data is going to be deleted from DB continue (y/n)?"
validargs="y,n"
exitargs="n"
/>
</target>

@@ -32,7 +23,6 @@
<input testinput="y"
message="All data is going to be deleted from DB continue (y/n)?"
validargs="y,n"
exitargs="n"
/>
</target>

@@ -43,13 +33,4 @@
/>
</target>

<target name="test7">
<input testinput="R"
message="Press 'R' to make you very rich!"
validargs="R"
exitargs="R"
exitmessage="Don't trust if you don't have the source ;-)"
/>
</target>
</project>

+ 2
- 37
src/main/org/apache/tools/ant/taskdefs/Input.java View File

@@ -69,8 +69,6 @@ import org.apache.tools.ant.*;
*/
public class Input extends Task {
private String validargs = null;
private String exitargs = null;
private String exitmessage = "Build abborted.";
private String message = "";
private String addproperty = null;
private String input = null;
@@ -92,33 +90,12 @@ public class Input extends Task {
* according to property task which means that existing properties
* cannot be overriden.
*
* @param exitargs Name for the property to be created from input
* @param addproperty Name for the property to be created from input
*/
public void setAddproperty (String addproperty) {
this.addproperty = addproperty;
}

/*
* Defines exit condition parameters as comma separated String. If input
* matches one of these input task will end build by throwing a
* BuildException. ExitArgs are case sensitive. If you want the build to
* end on 'x' and 'X' you need to define both values as exit arguments.
*
* @param exitargs A comma separated String defining exit arguments.
*/
public void setExitargs (String exitargs) {
this.exitargs = exitargs;
}

/**
* Sets the ExitMessage which gets displayed when exiting the build run.
* Default is 'Build abborted.'
* @param exitmessage The exit message to be displayed.
*/
public void setExitmessage (String exitmessage) {
this.exitmessage = exitmessage;
}

/**
* Sets the Message which gets displayed to the user during the build run.
* @param message The message to be displayed.
@@ -154,14 +131,6 @@ public class Input extends Task {
accept.addElement(stok.nextToken());
}
}
Vector exit = null;
if (exitargs != null) {
exit = new Vector();
StringTokenizer stok = new StringTokenizer(exitargs, ",", false);
while (stok.hasMoreTokens()) {
exit.addElement(stok.nextToken());
}
}
log(message, Project.MSG_WARN);
if (input == null) {
try {
@@ -193,9 +162,6 @@ public class Input extends Task {
log("Override ignored for " + addproperty, Project.MSG_VERBOSE);
}
}
if (exit != null && exit.contains(input)) {
throw new BuildException(exitmessage);
}
}

// copied n' pasted from org.apache.tools.ant.taskdefs.Exit
@@ -203,8 +169,7 @@ public class Input extends Task {
* Set a multiline message.
*/
public void addText(String msg) {
message +=
ProjectHelper.replaceProperties(project, msg);
message += project.replaceProperties(msg);
}
}



+ 0
- 16
src/testcases/org/apache/tools/ant/taskdefs/InputTest.java View File

@@ -88,18 +88,6 @@ public class InputTest extends BuildFileTest {
}
}

public void test4() {
String log = "All data is going to be deleted from DB continue (y/n)?";
String message = "Build abborted.";
try {
executeTarget("test4");
} catch (org.apache.tools.ant.BuildException e) {
String realLog = getLog();
assertEquals(log, realLog);
assertEquals(message, e.getMessage());
}
}

public void test5() {
expectLog("test5",
"All data is going to be deleted from DB continue (y/n)?");
@@ -111,8 +99,4 @@ public class InputTest extends BuildFileTest {
assertEquals("scott", project.getProperty("db.user"));
}

public void test7() {
expectBuildException("test7",
"Don't trust if you don't have the source ;-)");
}
}

Loading…
Cancel
Save