I am trying to wrap my head around using CodeNarc inside of Gradle.
According to the CodeNarc docs, my project needs to have a config/codenarc/codenarc.xml
config file defined. But then I see plenty of example config files (such as this StarterRuleSet) that seem to use a Groovy DSL.
So I ask:
main.html
; how could I change the name of this file to, say, codenarc.html
?It looks like in your build.gradle
you can just put:
codenarc {
toolVersion = "0.20"
}
codenarcMain {
configFile = rootProject.file("path/to/CodeNarcMain.groovy")
}
codenarcTest {
configFile = rootProject.file("path/to/CodeNarcTest.groovy")
}
Where the file names (CodeNarcMain
, CodeNarcTest
) are whatever you want them to be.
Groovy DSL documentation is here. If you need to configure a specific rule, look it up in the documentation and if the rule has public properties that it exposes, they'll be listed in a table under the specific rule's documentation.
And it looks like you can only change the report file format (HTML, XML, text, console) but not the actual file name produced.