Marcus Junius Brutus
Marcus Junius Brutus

Reputation: 27286

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

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.

Upvotes: 5

Views: 3100

Answers (3)

Rebse
Rebse

Reputation: 10377

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.

Upvotes: 2

David W.
David W.

Reputation: 107050

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.

Upvotes: 1

chrislhardin
chrislhardin

Reputation: 1745

Wrap your calls in the sequential container.

http://ant.apache.org/manual/Tasks/sequential.html

Upvotes: 0

Related Questions