实际上,我需要将GMetrics静态代码分析工具与grails 3x应用程序集成在一起,但我无法做到这一点。
如果有人已经做过,请帮助我。
最佳答案
您的build.gradle文件中需要以下代码片段
configurations {
gmetrics
}
dependencies {
...
gmetrics 'org.gmetrics:GMetrics:0.7'
}
task gmetrics {
doLast {
//use GMetrics ant task - http://gmetrics.sourceforge.net/gmetrics-ant-task.html
ant.taskdef(name: 'gmetrics', classname: 'org.gmetrics.ant.GMetricsTask', classpath: configurations.gmetrics.asPath)
//ensure reporting directory created
ant.mkdir(dir: "${project.reporting.baseDir.path}/gmetrics")
ant.gmetrics() {
report(type: 'org.gmetrics.report.BasicHtmlReportWriter') {
option(name: 'outputFile', value: "${project.reporting.baseDir.path}/gmetrics/gmetrics.html")
}
report(type: 'org.gmetrics.report.XmlReportWriter') {
option(name: 'outputFile', value: "${project.reporting.baseDir.path}/gmetrics/gmetrics.xml")
}
fileset(dir: 'src') {
include(name: '**/*.groovy')
//exclusions to filter out any classes with inner classes - sonar doesn't support
exclude(name: '**/*Config*')
}
fileset(dir: 'grails-app') {
include(name: '**/*.groovy')
//exclusions to filter out any classes with inner classes - sonar doesn't support
exclude(name: '**/*Config*')
}
}
}
}
然后,您可以调用gmetrics任务,并在build / reports / gmetrics /中找到报告