Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant - Running a target at the end of every build

Tags:

ant

Is there a way to always run a target at the end of every build?

I know I can do something like this...

<target name="runJob" depends="actuallyRunJob, teardown"/>

... but that's sloppy, since I'd need a wrapper for every target that needs a teardown.

Any ideas?

Thanks, Roy

like image 899
Roy Truelove Avatar asked Jul 14 '11 15:07

Roy Truelove


People also ask

What is an Ant target?

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 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 you pass an argument to an Ant build?

Discussion. If you want to pass arguments to Ant, you can enter those arguments in the Arguments box of the dialog opened by right-clicking your build file, clicking Run Ant, and clicking the Main tab. You can see that dialog in Figure 7-15 (note that you also can set the build file location and base directory here).

What is PathElement in Ant?

Path: This object represents a path as used by CLASSPATH or PATH environment variable. A path might also be described as a collection of unique filesystem resources. and PathElement: Helper class, holds the nested <pathelement> values.


1 Answers

use a buildlistener, f.e. the exec-listener which provides a taskcontainer for each build result
( BUILD SUCCESSFUL | BUILD FAILED ) where you can put all your needed tasks in
see Conditional Task on exec failure in Ant for further details
or roll your own build listener, see =
http://ant.apache.org/manual/develop.html
and the api docs from your ant installation =
$ANT_HOME/docs/manual/api/org/apache/tools/ant/BuildListener.html

like image 197
Rebse Avatar answered Sep 27 '22 22:09

Rebse