Adam February 2016

Gradle Checkstyle Plugin Console Output

The Gradle Checkstyle plugin produces a lot of console output when Gradle is run with the -info option. This output tends to swamp more useful output from other tasks.

The plugin is configured as follows:

checkstyle {
    toolVersion = '6.15'
    configFile = file("$rootProject.projectDir/config/checkstyle/checkstyle.xml")
}

To see the problem, the build can be launched like this:

./gradlew clean checkStyleMain -info

The output then shows in the console as follows (edited for brevity!):

:core:checkstyleMain
Executing task ':core:checkstyleMain' (up-to-date check took 0.007 secs) due to:
....
[ant:xslt] Loading stylesheet <xsl:stylesheet    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
...
<xsl:template match="checkstyle">
    <html>
        <head>
        <style type="text/css">
...
</xsl:template>
...
</xsl:stylesheet>
:core:checkstyleMain (Thread[Daemon worker Thread 2,5,main]) completed. Took 0.878 secs.

The Gradle version is 2.10 and the Checkstyle plugin version is 6.15.

Does anyone know how to reduce or suppress the console output from the Checkstyle tasks?

Answers


RaGe February 2016

If you want to temporarily change the log level for just one task, you can do:

checkstyleMain{
    logging.setLevel(LogLevel.LIFECYCLE)
}

Logging will revert back to default, in your case, -info once this task is completed.


Adam February 2016

The answer from @RaGe is the solution to the problem I posed. If you'd also like to reduce the Checkstyle output for the analysis of the test code in addition to the main code, use the following instead:

[checkstyleMain, checkstyleTest].each { task ->
    task.logging.setLevel(LogLevel.LIFECYCLE)
}

Post Status

Asked in February 2016
Viewed 1,118 times
Voted 7
Answered 2 times

Search




Leave an answer