Gradle Checkstyle Plugin Console Output

早过忘川 提交于 2019-12-10 19:24:29

问题


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?


回答1:


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.




回答2:


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)
}


来源:https://stackoverflow.com/questions/35275783/gradle-checkstyle-plugin-console-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!