Mat*_*aun 18 checkstyle gradle build.gradle
我想通过Gradle将Checkstyle的输出作为HTML报告.
我在Checkstyle插件文档中找不到任何内容.
我已将以下内容添加到我的build.gradle文件中.
checkstyleTask {
reports {
html {
destination "build/reports/checkstyle.html"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但这产生了
出了什么问题:评估根项目'MyProject'时出现问题.
无法在根项目"MyProject"上找到参数[build_1vu33nc0ekgtoo19jt e86o8o42 $ _run_closure8 @ 1d8ee20]的方法checkstyleTask().
有没有办法使用Gradle生成Checkstyle HTML报告?
谢谢.
JB *_*zet 19
这是我在我的一个小项目中的表现:
checkstyleMain << {
ant.xslt(in: reports.xml.destination,
style: new File('config/checkstyle-noframes-sorted.xsl'),
out: new File(reports.xml.destination.parent, 'main.html'))
}
Run Code Online (Sandbox Code Playgroud)
这要求您将checkstyle二元分发的contrib目录中的checkstyle-noframes-sorted.xsl文件存储在config项目目录中.
如果您能负担得起运行SonarQube服务器,使用声纳插件可以带来更好的用户体验.
编辑:如果有违规行为,上述行为将无效.这应该在所有情况下:
task checkstyleHtml << {
ant.xslt(in: checkstyleMain.reports.xml.destination,
style: file('/config/checkstyle-noframes-sorted.xsl'),
out: new File(checkstyleMain.reports.xml.destination.parent, 'main.html'))
}
checkstyleMain.finalizedBy checkstyleHtml
Run Code Online (Sandbox Code Playgroud)
小智 5
看来我参加聚会迟到了。但是仍然发布这个认为它可能会帮助其他人解决同样的问题。
Gradle 2.10 支持 html 文件报告生成。只需确保您在gradle-wrapper.properties文件中正确配置了版本。
之后,在您的build.gradle文件中,您应该具有如下配置。
apply plugin: 'checkstyle'
checkstyle {
toolVersion = '6.4.1'
sourceSets = [sourceSets.main]
configFile = rootProject.file("config/checkstyle/checkstyle.xml");
showViolations = true
ignoreFailures = true
}
checkstyleTest {
enabled = false
}
tasks.withType(Checkstyle) {
reports {
html.destination rootProject.file("build/reports/checkstyle.html")
}
}
Run Code Online (Sandbox Code Playgroud)
这config file是包含您要使用的 checkstyle 模块的文件,html.destination也是您希望生成 html 报告的位置。
| 归档时间: |
|
| 查看次数: |
9542 次 |
| 最近记录: |