ant-user mailing list archives

Site index · List index
Message view
Top
From "Krystan Honour" <khon...@allstor-sw.co.uk>
Subject Re: Prompt
Date Mon, 12 Nov 2001 15:30:33 GMT
```Well,

I didn't actually use those classes but I did use them as templates to write
my own so I had the practice of writing a task. It does seem to me that ant
could be very powerful when used in conjunction with other tools, here I'm
thinking specifically of JUnit or jikes, slapping things through perl
scripts and python into our automated build process here looks to be childs
play. I am very happy I had a look at ant and in three days I have nuked my
Makefiles and have been able to write build.xml files and now we can test
compile on things much more robustly. I can see ant becoming indispensable
around here. So to answer your question yup this looks like a winner.

Krystan
----- Original Message -----
From: "Alan Pearlman Spencer" <Alan.PearlmanSpencer@Mobileaware.com>
To: "Krystan Honour" <khonour@allstor-sw.co.uk>
Sent: Monday, November 12, 2001 3:24 PM
Subject: RE: Prompt

>
> Great.
> Happy I could help.
> Is it going OK? I have not used these utilities yet...
> Alan.
>
> -----Original Message-----
> From: Krystan Honour [mailto:khonour@allstor-sw.co.uk]
> Sent: 12 November 2001 15:19
> To: Alan Pearlman Spencer
> Subject: Re: Prompt
>
>
> apologies for the direct mail this was NOT intended I have fixed my
> problems
>
> thank you for your courteous response.
>
> Krys
> ----- Original Message -----
> From: "Alan Pearlman Spencer" <Alan.PearlmanSpencer@Mobileaware.com>
> To: "Ant Users List" <ant-user@jakarta.apache.org>
> Sent: Monday, November 12, 2001 1:33 PM
> Subject: RE: Prompt
>
>
> >
> > Try this:
> > http://www.mail-archive.com/ant-user@jakarta.apache.org/msg03059.html
> > It has a custom task to ask the user a question...
> > Alan.
> >
> > -----Original Message-----
> > From: Krystan Honour [mailto:khonour@allstor-sw.co.uk]
> > Sent: 12 November 2001 13:20
> > To: Ant Users List
> > Cc: pperevalov@cyber-asp.com
> > 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" <pperevalov@cyber-asp.com>
> > To: "Ant Users List" <ant-user@jakarta.apache.org>
> > 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
> > javascript
> > > support.
> > >
> > > Paul Perevalov
> > >
> > > -----Original Message-----
> > > From: Mark Claassen [mailto:mac@donnell.com]
> > > 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:pperevalov@cyber-asp.com]
> > > > 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
> > > > 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
> > > >    <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:mac@donnell.com]
> > > > Sent: Friday, November 09, 2001 11:51 AM
> > > > To: ant-user@jakarta.apache.org
> > > > 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:mark.claassen@donnell.com
> > > > Voice: (219)232-3784
> > > > Fax: (219)232-4014
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <mailto:ant-user-help@jakarta.apache.org>
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <mailto:ant-user-help@jakarta.apache.org>
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:ant-user-help@jakarta.apache.org>
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:ant-user-help@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:ant-user-help@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:ant-user-help@jakarta.apache.org>
> >
>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>