You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Yiling Lu <yl...@invoqsystems.com> on 2004/08/20 02:05:55 UTC
RE: Can Ant exit itself? solution not correct
Hi,
My posted "solution" in the previous email is NOT correct.
Still in the quest for the solution of "make Ant exit gracefully"
Thank you
Yiling
-----Original Message-----
From: Yiling Lu
Sent: Thursday, August 19, 2004 4:51 PM
To: Ant Users List
Subject: RE: Can Ant exit itself?
This is a good question.
You never know what people are going to do with Ant ;-)
In short, my build starts with check outing properties files from
repository for each user@machine-name, if the user@machine-name does not
exist in the
Reposity in the first place, then Ant script will check out a default
property file from the repository. At this point, I ask the user if
he/she
Wants to modify this default property file or not. If the answer is no,
then
The build will continue. If the answer is yes, then the script is
suppose to exit gracefully with some message.
When users starts to use Ant extensively, there will comes use cases
that have not been thought about.
I found my solution. Create a target that does nothing, then call this
target using antcall. Ant will exit gracefully this way.
Thank you for all the responses.
Yiling
-----Original Message-----
From: Charles Hudak [mailto:charles.hudak@cardionet.com]
Sent: Thursday, August 19, 2004 4:24 PM
To: Ant Users List
Subject: RE: Can Ant exit itself?
Why do you want user interaction in your build script? It's one thing to
prompt a user for properties but Ant is not a UI and IMHO build scripts
should AUTOMATE your builds, not rely on user interaction and prompting.
This can usually all be done with property files for each build target
(e.g. production, development, etc) that allow user overrides via a file
placed in their home directory. If a user quits in the middle of a
build, was the build really 'Succesful'?
> -----Original Message-----
> From: Yiling Lu [mailto:ylu@invoqsystems.com]
> Sent: Thursday, August 19, 2004 4:17 PM
> To: Ant Users List
> Subject: RE: Can Ant exit itself?
>
>
> I am using Ant 1.6.2
>
> When I do <fail/> as the Ant manual suggested, the script
> actually failed for real. The reason is that I did not supply
> a message. But I do not want
> To supply a message and let ant to print out the message as
> fail information.
>
> In my case, I want to exit the program normally. <fail/> does
> not seem To do the work.
>
>
>
> Yiling
>
> -----Original Message-----
> From: Anderson, Rob (Global Trade) [mailto:Rob.Anderson@nike.com]
> Sent: Thursday, August 19, 2004 3:35 PM
> To: Ant Users List
> Subject: RE: Can Ant exit itself?
>
> <fail> task.
>
> -Rob A
>
> > -----Original Message-----
> > From: Yiling Lu [mailto:ylu@invoqsystems.com]
> > Sent: Thursday, August 19, 2004 2:48 PM
> > To: Ant Users List
> > Subject: Can Ant exit itself?
> >
> >
> > Hi folks,
> >
> >
> >
> > I am using Ant to prompt the user to choose continue or
> quit the ant
> > script.
> >
> >
> >
> > I could not find an Ant task that will quit the Ant script
> gracefully.
> > Could you please
> >
> > Help me out here?
> >
> >
> >
> > Thank you.
> >
> >
> >
> > Yiling
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Can Ant exit itself? solution not correct
Posted by Ivan Ivanov <ra...@yahoo.com>.
Hi, i think that this will help you
<project name="thejob" basedir="."
default="do-the-job">
<target name="do-the-job" depends="check-user"
if="is.confirmed">
<echo message="Doing the nice build"/>
</target>
<target name="check-user">
<input message="Continue? (yes/no)"
addproperty="confirm"/>
<condition property="is.confirmed">
<equals arg1="${confirm}" arg2="yes"
trim="true"/>
</condition>
</target>
</project>
Here when do-the-job target is invoked it first calls
check-user target. It asks the user for confirmation
and if she has typed in yes is.confirmed property is
set. Next do-the-job target continues and checks
whether is.confirmed is set and if so it executes.
So you place in do-the-job the stuff you want to do
after the user confirms that she does not want to edit
the properties files. The problem I foresee is if the
stuff is quite a lot, it will be ugly to be packed in
one target. You might need <ant> or <antcall> (which I
haven't used for 3 years) to call other targets from
do-the-job.
Anyway here is the output of two runs of the above
file
-------
$ ant -f thejob.xml
Buildfile: thejob.xml
check-user:
[input] Continue? (yes/no)
yes
do-the-job:
[echo] Doing the nice build
---------
$ ant -f thejob.xml
Buildfile: thejob.xml
check-user:
[input] Continue? (yes/no)
no
do-the-job:
---------------
Perhaps this is what you want.
HTH Ivan
P.S. In <input> task you can use validargs to specify
the valid values the user can input.
--- Yiling Lu <yl...@invoqsystems.com> wrote:
> Hi,
>
> My posted "solution" in the previous email is NOT
> correct.
>
> Still in the quest for the solution of "make Ant
> exit gracefully"
>
> Thank you
>
> > Yiling
>
> -----Original Message-----
> From: Yiling Lu
> Sent: Thursday, August 19, 2004 4:51 PM
> To: Ant Users List
> Subject: RE: Can Ant exit itself?
>
> This is a good question.
> You never know what people are going to do with Ant
> ;-)
>
> In short, my build starts with check outing
> properties files from
> repository for each user@machine-name, if the
> user@machine-name does not
> exist in the
> Reposity in the first place, then Ant script will
> check out a default
> property file from the repository. At this point, I
> ask the user if
> he/she
> Wants to modify this default property file or not.
> If the answer is no,
> then
> The build will continue. If the answer is yes, then
> the script is
> suppose to exit gracefully with some message.
>
> When users starts to use Ant extensively, there will
> comes use cases
> that have not been thought about.
>
> I found my solution. Create a target that does
> nothing, then call this
> target using antcall. Ant will exit gracefully this
> way.
>
> Thank you for all the responses.
>
> Yiling
>
> -----Original Message-----
> From: Charles Hudak
> [mailto:charles.hudak@cardionet.com]
> Sent: Thursday, August 19, 2004 4:24 PM
> To: Ant Users List
> Subject: RE: Can Ant exit itself?
>
> Why do you want user interaction in your build
> script? It's one thing to
> prompt a user for properties but Ant is not a UI and
> IMHO build scripts
> should AUTOMATE your builds, not rely on user
> interaction and prompting.
> This can usually all be done with property files for
> each build target
> (e.g. production, development, etc) that allow user
> overrides via a file
> placed in their home directory. If a user quits in
> the middle of a
> build, was the build really 'Succesful'?
>
> > -----Original Message-----
> > From: Yiling Lu [mailto:ylu@invoqsystems.com]
> > Sent: Thursday, August 19, 2004 4:17 PM
> > To: Ant Users List
> > Subject: RE: Can Ant exit itself?
> >
> >
> > I am using Ant 1.6.2
> >
> > When I do <fail/> as the Ant manual suggested, the
> script
> > actually failed for real. The reason is that I did
> not supply
> > a message. But I do not want
> > To supply a message and let ant to print out the
> message as
> > fail information.
> >
> > In my case, I want to exit the program normally.
> <fail/> does
> > not seem To do the work.
> >
> >
> >
> > Yiling
> >
> > -----Original Message-----
> > From: Anderson, Rob (Global Trade)
> [mailto:Rob.Anderson@nike.com]
> > Sent: Thursday, August 19, 2004 3:35 PM
> > To: Ant Users List
> > Subject: RE: Can Ant exit itself?
> >
> > <fail> task.
> >
> > -Rob A
> >
> > > -----Original Message-----
> > > From: Yiling Lu [mailto:ylu@invoqsystems.com]
> > > Sent: Thursday, August 19, 2004 2:48 PM
> > > To: Ant Users List
> > > Subject: Can Ant exit itself?
> > >
> > >
> > > Hi folks,
> > >
> > >
> > >
> > > I am using Ant to prompt the user to choose
> continue or
> > quit the ant
> > > script.
> > >
> > >
> > >
> > > I could not find an Ant task that will quit the
> Ant script
> > gracefully.
> > > Could you please
> > >
> > > Help me out here?
> > >
> > >
> > >
> > > Thank you.
> > >
> > >
> > >
> > > Yiling
> > >
> > >
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> user-help@ant.apache.org
> >
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> user-help@ant.apache.org
> >
> >
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org