Support for Grails 3.x?
Closed this issue · 3 comments
This is a carryover and response to issue GPCODENARC-46 on jira.grails.org (which was since shutdown), asking about support for Grails 3.x.
As documented at https://github.com/grails/grails-core/wiki/Grails-3-Priority-Upgrade-Plugins, the Grails CodeNarc Plugin has been "replaced" by the Gradle CodeNarc plugin (https://docs.gradle.org/current/userguide/codenarc_plugin.html) for Grails 3.x and beyond.
I agree that the Gradle plugin documentation is not terribly easy to use; it expects a good bit of Gradle knowledge/experience.
I was able to get the Gradle CodeNarc plugin working with Grails 3.x.
------------------------------------------------------------
Gradle 2.12
------------------------------------------------------------
| Grails Version: 3.1.4
| Groovy Version: 2.4.6
| JVM Version: 1.7.0_51
I added this to build.gradle:
apply plugin:"codenarc"
codenarc {
config = resources.text.fromFile('codenarc-ruleset.groovy')
}
I added a new “codenarc-ruleset.groovy” file in the project root folder (as an example; customize for yourself):
ruleset {
ruleset('rulesets/basic.xml')
ruleset('rulesets/groovyism.xml')
ruleset('rulesets/naming.xml')
ruleset('rulesets/unused.xml')
ruleset('rulesets/unnecessary.xml')
}
And then executed:
gradle codenarcMain
@chrismair Do you know where to add the codenarc.properties in the Grails 3 project? I tried adding it in different places but it doesn't seem to be reading it.
I'll try and take a look.
I was able to specify the location of the "codenarc.properties" file by setting the "codenarc.properties.file" system property to a file:
URL, e.g.:
gradle codenarcMain -Dcodenarc.properties.file=file:codenarc.properties