In my ant script, I have target, which zipped a project. How can I start another target after this target finished?
Thanks a lot!
To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.
An Ant target is a sequence of tasks to be executed to perform a part (or whole) of the build process. Ant targets are defined by the user of Ant. Thus, what tasks an Ant target contains depends on what the user of Ant is trying to do in the build script.
which you can then set as the default, so just typing ant will list the available targets. small suggestion. make "help" target as default. As a result running "ant" will invoke "help" target that will print all available targets.
Online documentation and books say that target is a stage of the entire build process, while task is the smallest unti of work.
Let's assume the target you have is zip-project
and the next target you want to execute is next-target-for-something
One way of doing this is using antcall
<target name="zip-project">
<!-- Your Zipping Task-->
<antcall target="next-target-for-something"/>
</target>
Remember antcall
can be invoked inside a target
only
Another way of doing this is using depends
You would have something like:
<target name="zip-project" >
<!-- Your Zipping Task-->
</target>
Now define the next task as
<target name="next-target-for-something" depends="zip-project" >
<!-- Your Next Task-->
</target>
though this works in opposite manner of what you would have asked. So you need to call the ant like...
ant -buildfile <build.xml> next-target-for-something
and it will make sure that first zip-project
is completed and then next-target-for-something
will be executed.
Hope this helps!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With