Ta, Have been able to do this now using a custom task. However this was an extremely useful exercise in how to do things like this.
Regards Krys ----- Original Message ----- From: "Paul Perevalov" <[EMAIL PROTECTED]> To: "Ant Users List" <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 3:21 PM Subject: Re: Prompt > > I do all my development on windows, for unix "con" should be replaced on > "/dev/stdin". > You can hardcode this :) or just add a little code snippet to make this > target platform independent (I didn't test it on unix, so probably you have > to test it a little bit): > > > //get os name > var os = project.getProperty("os.name"); > var console; > > //select appropriate input > if(os.charAt(0) == 'W' || os.charAt(0) == 'w'){ > console = "con"; > }else{ > console = "/dev/stdin"; > } > > //get standart input stream > var stdin = new BufferedReader(new InputStreamReader(new > FileInputStream(console))); > > Just add this code to the target and remove duplicate line where new > BufferedReader is created. > > Hope this help. > > Paul Perevalov > > -----Original Message----- > From: Krystan Honour [mailto:[EMAIL PROTECTED]] > Sent: Monday, November 12, 2001 8:20 AM > To: Ant Users List > Cc: [EMAIL PROTECTED] > Subject: Re: Prompt > > > Hi, > > this is extremely useful. Only one problem I ran this successfully under > windows which prompted for a password that I use to sign my jars with and > signed it. When I tried to use the same script under linux I get a file not > found exception because it can't find the file "con" ? which is asked for > in > the stream handler. Any ideas ? > > Krys > ----- Original Message ----- > From: "Paul Perevalov" <[EMAIL PROTECTED]> > To: "Ant Users List" <[EMAIL PROTECTED]> > Sent: Friday, November 09, 2001 8:02 PM > Subject: RE: Prompt > > > > > > You have to add in ant\lib directory bsf.jar from > > http://oss.software.ibm.com/developerworks/projects/bsf for script task > > and js.jar from http://www.mozilla.org/rhino/download.html for javascript > > support. > > > > Paul Perevalov > > > > -----Original Message----- > > From: Mark Claassen [mailto:[EMAIL PROTECTED]] > > Sent: Friday, November 09, 2001 2:52 PM > > To: Ant Users List > > Subject: RE: Prompt > > > > > > Thanks! It will take me a while to get through all this, but this sounds > > like just the ticket. Will ant run this just by itself, or do I need > > something to help it with the JavaScript? I tried in using the ant1.3 > that > > is bundled in with netbeans 3.2.1 and it didn't work. Maybe the optional > > tasks are not included by default. > > > > Mark > > > > > -----Original Message----- > > > From: Paul Perevalov [mailto:[EMAIL PROTECTED]] > > > Sent: Friday, November 09, 2001 12:16 PM > > > To: Ant Users List > > > Subject: RE: Prompt > > > > > > > > > I wrote my own target which uses javascript to get some user input into > > > properties and then run another tagets. > > > You can place this target in common build file and then include it main > > > build file. > > > Here is the target itself, after this target you can find example > > > how to use > > > it. > > > > > > <target name="doTargetWithUserInput" description="Executes target > > > where some > > > parameters provided by user from kbd."> > > > <script language="javascript"> <![CDATA[ > > > importPackage(Packages.java.lang); > > > importPackage(Packages.java.io); > > > project = doTargetWithUserInput.getProject(); > > > //get comma separated user prompts > > > var prompts = project.getProperty("prompts"); > > > //get comma separated user properties which should be set > > > var properties = project.getProperty("properties"); > > > //get comma separated targets to be executed > > > var targets = project.getProperty("targets"); > > > > > > //get standart input stream > > > var stdin = new BufferedReader(new InputStreamReader(new > > > FileInputStream("con"))); > > > > > > //split prompts,properties and targets to arrays > > > var arrPrompts = Split(String(prompts),","); > > > var arrProperties = Split(String(properties),","); > > > var arrTargets = Split(String(targets),","); > > > > > > //fail if number of properties does not match to number of prompts > > > if(arrPrompts.length != arrProperties.length){ > > > fail = project.createTask("fail"); > > > fail.setMessage("Number of prompts does not match to the number of > > > properties."); > > > fail.execute(); > > > } > > > > > > //get value for each property from user by showing corresponding > prompt > > > var temp = ""; > > > for (var i = 0; i < arrPrompts.length; i++){ > > > System.out.println(arrPrompts[i]); > > > temp = stdin.readLine(); > > > project.setProperty(arrProperties[i],temp); > > > } > > > > > > //execute each target which now will have access to new properties > > > for (var j = 0; j < arrTargets.length; j++){ > > > project.executeTarget(arrTargets[j]); > > > } > > > > > > function Split(Expression, Delimiter) > > > { > > > var temp = Expression; > > > var a, b = 0; > > > var array = new Array(); > > > > > > if (Delimiter.length == 0) > > > { > > > array[0] = Expression; > > > return (array); > > > } > > > > > > if (Expression.length == '') > > > { > > > array[0] = Expression; > > > return (array); > > > } > > > > > > Delimiter = Delimiter.charAt(0); > > > > > > for (var i = 0; i < Expression.length; i++) > > > { > > > a = temp.indexOf(Delimiter); > > > if (a == -1) > > > { > > > array[i] = temp; > > > break; > > > } > > > else > > > { > > > b = (b + a) + 1; > > > var temp2 = temp.substring(0, a); > > > array[i] = temp2; > > > temp = Expression.substr(b, > > > Expression.length - temp2.length); > > > } > > > } > > > > > > return (array); > > > } > > > > > > ]]></script> > > > </target> > > > > > > Then you can use this target to get some user input and run another > > > target(s). > > > > > > <antcall target="doTargetWithUserInput"> > > > <param name="prompts" value="Enter user ID:,Enter user password:"/> > > > <param name="properties" value="user,pwd"/> > > > <param name="targets" value="doSomething"/> > > > </antcall> > > > > > > <target name="doSomething" description="Do something with user input"> > > > <echo message="User id: ${user}, password : ${pwd}"/> > > > </target> > > > > > > Hope this help. > > > > > > Paul Perevalov > > > > > > -----Original Message----- > > > From: Mark Claassen [mailto:[EMAIL PROTECTED]] > > > Sent: Friday, November 09, 2001 11:51 AM > > > To: [EMAIL PROTECTED] > > > Subject: Prompt > > > > > > > > > Is there any way to prompt for information during a script > > > (without writing > > > a custom task)? When I compile my code for release, we tag it in CVS. > > We > > > then use this tag name in the code to generate the version numbers. > > > > > > What I would like to do is have ant prompt me for a tag and a > > > branch. Then > > > it could automatically check out the correct tagged version of the > files > > > that contain the $Name$, compile it (with the $Name$ expanded), > > > build jars, > > > and then checkout the head of the branch again so I am where I left > off. > > > > > > I could do this with command line parameters as well, but using > > > it this way > > > in netbeans is a little less convenient. > > > > > > Thanks for your time, > > > Mark > > > > > > --------------------- > > > Mark Claassen > > > Donnell Systems, Inc. > > > 300 S. St. Louis Blvd. Ste. 203 > > > South Bend, IN 46617 > > > E-mail: mailto:[EMAIL PROTECTED] > > > Voice: (219)232-3784 > > > Fax: (219)232-4014 > > > > > > > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>