java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4088
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Input task E-mail
User Rating: / 4
PoorBest 

Input

Description

Allows user interaction during the build process by prompting for input. To do so, it uses the configured InputHandler.

The prompt can be set via the message attribute or as character data nested into the element.

Optinonally a set of valid imput arguments can be defined via the validargs attribute. Input task will no accept value that don't match one of the predefined.

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 property task which means that existing properties cannot be overriden. Since Ant 1.6, <input> will not prompt for input if a property should be set by the task that has already been set in the project (and the task wouldn't have any effect).

Parameters

Attribute Description Required
message the Message which gets displayed to the user during the build run. No
validargs comma separated String containing valid input arguments. If set, input task will reject any input not defined here. Validargs are compared case sensitive. If you want 'a' and 'A' to be accepted you will need to define both arguments within validargs. No
addproperty the name of a property to be created from input. Behaviour is equal to property task which means that existing properties cannot be overriden. No
defaultvalue Defines the default value of the property to be created from input. Property value will be set to default if no input is received. No

Examples

  <input/>

Will pause the build run until return key is pressed when using the default InputHandler, the concrete behavior is defined by the InputHandler implementation you use.

  <input>Press Return key to continue...</input>

Will display the message "Press Return key to continue..." and pause the build run until return key is pressed (again, the concrete behavior is implementation dependent).

  <input
    message="Press Return key to continue..."
  />

Will display the message "Press Return key to continue..." and pause the build run until return key is pressed (see above).

  <input
    message="All data is going to be deleted from DB continue (y/n)?"

    validargs="y,n"
    addproperty="do.delete"
  />
  <condition property="do.abort">
    <equals arg1="n" arg2="${do.delete}"/>

  </condition>
  <fail if="do.abort">Build aborted by user.</fail>

Will display the message "All data is going to be deleted from DB continue (y/n)?" and require 'y' to continue build or 'n' to exit build with following message "Build aborted by user.".

  <input
    message="Please enter db-username:"
    addproperty="db.user"
  />

Will display the message "Please enter db-username:" and set the property db.user to the value entered by the user.

  <input
    message="Please enter db-username:"
    addproperty="db.user"
    defaultvalue="Scott-Tiger"
  />

Same as above, but will set db.user to the value Scott- Tiger if the user enters no value (simply types <return>).

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.