Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant : how to always execute a task at the end of every run (regardless of target)

Tags:

ant

Is there a way to define a task in Ant that always gets executed at the end of every run? This SO question provides a way to do so, at the start of every run, before any other targets have been executed but I am looking at the opposite case.

My use case is to echo a message warning the user if a certain condition was discovered during the run but I want to make sure it's echoed at the very end so it gets noticed.

like image 707
Marcus Junius Brutus Avatar asked Oct 23 '22 04:10

Marcus Junius Brutus


2 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 :
https://stackoverflow.com/a/6391165/130683
for details.

like image 188
Rebse Avatar answered Oct 29 '22 21:10

Rebse


It's an interesting situation. Normally, I would say you can't do this in an automated way. You could wrap Ant in some shell script to do this, but Ant itself really isn't a full fledge programming language.

The only thing I can think of is to add an <ant> call at the end of each task to echo out what you want. You could set it up, that if a variable isn't present, the echo won't happen. Of course, this means calling the same target a dozen or so times just to get that final <echo>.

I checked through AntXtras and Ant-Contrib for possible methods, but couldn't find any.

Sorry.

like image 27
David W. Avatar answered Oct 29 '22 21:10

David W.