Capturing Gradle's terminal output?


(Jonathan Chien) #1

I’m trying to implement a large custom plugin, and one of the features is to email the terminal output of a release. I’ve set up a StandardOutputListener to simply capture all output (concatenates any new output to its existing String) and called addStandardOutputListener and addStandardErrorListener of the LoggingManager of each project as well as the root project (dunno if they’re shared, but did this just in case they weren’t) on the listener.

However, the listener’s log is always blank unless debug mode is on, in which case it captures two lines. Essentailly, what I want is everything that’s printed to the Terminal, e.g:

:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes
:buildSrc:jar
:buildSrc:assemble
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test
:buildSrc:check
:buildSrc:build FAILED
  FAILURE: Build failed with an exception.

Any help would be appreciated. Thanks!


(Jonathan Chien) #2

I was able to do this by implementing a custom Logger (was hoping to avoid boilerplate of all those methods, but oh well).

One thing that I did notice in testing though is that Gradle only ever seems to call the log() methods with the LogLevel and never the direct methods (quiet, lifecycle, trace, info, etc.) Is this true of all Gradle messages as of 1.6?