Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant start target after

In my ant script, I have target, which zipped a project. How can I start another target after this target finished?

Thanks a lot!

like image 833
EK. Avatar asked Aug 06 '12 14:08

EK.


People also ask

How do you trigger an Ant build?

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.

How do Ant targets work?

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.

How do you list Ant targets?

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.

What is the difference between task and target?

Online documentation and books say that target is a stage of the entire build process, while task is the smallest unti of work.


1 Answers

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!!

like image 173
Bharat Sinha Avatar answered Sep 19 '22 16:09

Bharat Sinha