Externalized BuildConfig in Grails

We can load various configuration files for Config.groovy by specifying the class, which is the configuration script. External setting :

 grails.config.locations = [com.my.app.MyConfig] 

Can I do something similar for BuildConfig.groovy ?

I want to place the CodeNarc configuration in another configuration file. Since it uses Groovy ConfigSlurper syntax, I am trying to combine configuration objects, but it does not work.

 def config = new ConfigSlurper().parse(..) this.merge(config) 

Any trick?

+4
source share
1 answer

You do not need it.

The Codenarc plugin allows you to save the configuration of the knuckles externally. Take a look here http://grails.org/plugin/codenarc#Configuring Codenarc Properties

Here is an example of setting up the code that I have in BuildConfig.groovy

 codenarc.processTestUnit = false codenarc.processTestIntegration = false codenarc.processViews = true codenarc.propertiesFile = 'grails-app/conf/codenarc.properties' codenarc.ruleSetFiles = [ "rulesets/basic.xml", "rulesets/braces.xml", "rulesets/grails.xml", "rulesets/groovyism.xml", ] 

Here we also define the external codenarc.properties file, which we use to enable / disable parts of the rules from each included rule set. An example of this codenarc.properties content is here:

 # some gsp MUST have embedded CSS and/or embedded Javascript which requires the use of semicolons. UnnecessarySemicolon.doNotApplyToFileNames = *.gsp # we're not going to enforce these UnnecessaryGString.enabled = false UnnecessaryReturnKeyword.enabled = false 

So, you can avoid polluting your BuildConfig with the unnecessary things that Thomas mentioned.

Hope this helps.

Tom

+1
source

All Articles