Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I intercept or elevate log messages when calling an Ant task from Gradle

Tags:

gradle

ant

I call ant.signjar from a gradle script. How can I capture its output? I did neither get it managed easily to elevate the output from INFO to another level, nor to intercept or wrap the output to error warnings out to WARN level. Currently the signjar echoes out that the certificate will expire soon, but this is not shown on WARN level which is not so nice.

like image 842
Vampire Avatar asked Jul 10 '12 12:07

Vampire


1 Answers

I assume the Ant task is using Ant's logging framework, and not just printing to standard out. In that case, have you tried the following?

task taskThatCallsAntTask {
    logging.level = LogLevel.INFO
}

When configured in this way, the log level will be changed to INFO while the task is executing (and reverted back afterwards), no matter which log level is set when invoking Gradle. Note that you can't elevate the log level of an Ant log event; it's up to the Ant task at which level it logs.

like image 147
Peter Niederwieser Avatar answered Oct 02 '22 14:10

Peter Niederwieser