You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Sanjay Bhatia <sb...@yahoo.com> on 2001/06/16 05:08:59 UTC
Conditional statement within a target
Hi,
I have a target that creates and then includes a file into a jar. I would like
to be able to specify something on the command line that will either do this or
not. I checked out the docs and it is possible to do something similar for a
target, but nothing to answer this question.
Has anyone done this before? Please mail me your suggestions.
Thanks,
sb
__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
Re: Conditional statement within a target
Posted by Stefan Bodewig <bo...@apache.org>.
Sanjay Bhatia <sb...@yahoo.com> wrote:
> I have a target that creates and then includes a file into a jar. I
> would like to be able to specify something on the command line that
> will either do this or not.
Not sure whether I understand your problem. You have something like
<target name="to-run-or-not-to-run">
<create-file />
<add-file-to-jar />
</target>
If you want to do this, you can say
ant to-run-or-not-to-run my-other-targets
and if you don't want to run it:
ant my-other-targets
But maybe your situation is more complicated? You have a target named
must-run that depends on to-run-or-not-to-run if this should run - and
you want to run must-run anyway? Then you could do
<target name="to-run-or-not-to-run" if="run">
...
</target>
<target name="must-run" depends="to-run-or-not-to-run">
...
</target>
and use either "ant -Drun=1 must-run" or just "ant must-run".
Does this cover your problem?
Stefan