Interception of ant task output


(Björn Kautler) #1

I called ant.signjar from a gradle script (I’m doing it in-process now because of performance, but the idea holds true for other cases). I’d like to intercept or wrap the output to echo warnings out to WARN level or do other things with the output. Currently the signjar echoes out that the certificate will expire soon, but this is not shown on WARN level which is not so nice.


(Eric Berry) #2

Hi Vampire. I think your problem is related to how Gradle process Ant’s system.out logging.

From the ant docs, echo goes to system.out unless logging is overridden: http://ant.apache.org/manual//Tasks/echo.html

Here’s an old mailing list message that I think applies to your problem. http://gradle.1045684.n5.nabble.com/How-to-log-ant-stdout-with-gradle-td1433435.html

I think you may be able to solve your problem by setting the log level in your build.gradle file: http://gradle.1045684.n5.nabble.com/capture-ant-logging-and-clean-lt-taskName-gt-td4746476.html

Hope that helps, Eric


(Björn Kautler) #3

Hi Eric,

unfortunately it doesn’t. Peter als suggested this to my question here: http://stackoverflow.com/questions/11413559/how-do-i-intercept-or-elevate-log-messages-when-calling-an-ant-task-from-gradle But that is not what I’m after, as this is too coarse grained. I do not want all output of the ant task, I just want to see the warnings. So either the Ant logging has to be instrumented so that the Ant logging messages go to the corresponding levels of the Gradle logging system, or / and there should be a way to intercept and process the logging output. The latter one is what this idea suggests.

Cheers Vampire


(Eric Berry) #4

Hey Vampire,

My mistake, thought this was under the bugs category. :slight_smile: Cheers, Eric