I have an ant buildfile that is often run from vastly different environments. By default, I'm looking for the same behavior as using:
ant -q
However, since some team member's configurations vary, specifying the -q option in each person's environment is not easily accomplished in a uniform way (some people run ant from eclipse, some from the command line, some from debugging/profiling tools, etc. Each with a different method for specifying ant arguments like -q)
So I'm seeking a way for the ant file to call itself quietly...
Something like the following would be ideal:
<target name="default">
<antcall quiet="yes" target="build" /> <!-- doesn't work -->
</target>
Can anyone think of anyway to accomplish something like this? All I'm after is for the build to run quietly whenever the default target is ran, regardless of whether -q is set.
For controlling the loglevel from within your ant script you could take this simple task =
map it to a taskdef and use it like that =
... only errors should be listed
... loglevel info again
That's what i do to shorten logfiles when using talkative tasks like f.e. cvs task
After reading Martin's answer, i think it's most comfortable to put the whole stuff in a scriptdef. Here's a solution with groovy =
Every scripting language running with Bean Scipting Framework in Java VM may be used for scripting in ant with full access to the ant api - it's a matter of taste. Used Javascript, Beanshell, (J)ruby before and lately switched to Groovy.
Based on other answers:
One option might be to set the logging level from within the target.
You can access loggers by means of a short script task. Something like:
I'm not familiar with how Eclipse calls Ant, but it might be necessary to iterate over all the build listeners to get 'silence' all round.
Suggest that how ever you end up doing this, you make it easy to switch back to verbose running.
Edit - response to comment: You can access project properties from within the script using
project.getProperty()
:(Somewhat old) API docs are here, including for the
project
class.