实际上我需要将GMetrics静态代码分析工具与grails 3x应用程序集成,但我无法做到。
如果有人已经做过,请帮帮我。
答案 0 :(得分:0)
您的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 /
中查找报告