Currently the Findbugs logs a lot of messages regarding Analyzing…, Scanning archives…, analysis passes, etc. These can be suppressed by adding -quiet to the command line or adding the following line to FindBugsExecuter:
commandLine.parse(new String[]{"-quiet"});
The biggest issue is that some of these messages get picket as targets by Jenkins, which totally ruins the layout of the build report page.
I tried to override the FindBugsExecuter from the buildSrc, but it was not picked up.
I would like to fix this issue, and passing the -quiet option is easy, but the problem is that I can’t even reproduce the problem. All I get as output when analyzing a project with FindBugs violations is
:findbugsMain
FindBugs rule violations were found. See the report at: file:///Users/jb/projects/foo/build/reports/findbugs/main.html
:compileTestJava
Could you please tell me which version of Gradle you’re using, and post a minimal example build file and Java source file which produces all those traces that you would like to avoid, along with an example of those traces?
Ok, I think I tracked it down to the following: FindBugsSpecBuilder adds the ‘-progress’ argument for FindBugs. That causes the TextUICommandLine class to do the following (from FindBugsExecutor)
Where ‘findBugs’ is an instance of FindBugs2. It appears that when this task is executed in a GradleWorker thread (parallel), then the “System.out” is not captured the same way that it is when the task is run in the GradleMain thread (non-parallel).
The output is a little weird, you have to scroll to the write to see it all. That’s copied from my terminal. I’m wondering if the parallel tasks being executed are stepping on each other on the OutputStream.
—Update— I’ve tried redirecting the stream to a file and looking at that and I see a bunch of ^M’s in the file where the terminal output gets wonky. I went back to the TextUIProgressCallback and it has this method:
Last night I tried a couple different things by patching the FindBugs library and found no difference in the output.
Digging through the Gradle code, I think it has to do with how StdOut and StdErr are captured from a GradleWorkerProcess.
The FindBugs task itself spawns a new WorkerProcess through the WorkerProcessFactory to actually execute the FindBugs task. When you run non-parallel, then the FindBugs task executes on GradleMain and it spawns a GradleWorkerMain and you don’t get any output.
However, when running in parallel mode, then GradleMain spawns a GradleWorkerMain to execute the FindBugs tasks, which itself spawns another GradleWorkMain to execute the actual FindBugs code and then the output appears on the console.
So it appears that when spawning a WorkerProcess from another WorkerProcess, StdOut and StdErr are not fowarded properly all the way back to the LoggingManager in GradleMain.
Ok, I’ve got to switch off this for awhile. But I did notice that the CodeNarc plugin has the same issue when executing in a parallel build, it’s output ends up on System.out instead of being captured by the LoggingManager.
I looked and the CodeNarc class does:
logging.captureStandardOutput(LogLevel.INFO)
and then executes an Ant task.
So it seems that that capturing just isn’t working correctly in parallel builds when a child process is being launched. I don’t think I can take this one any further.