chris
chris

Reputation: 7583

How to override plugin Config in Grails?

I'm using the excellent class-diagram plugin https://github.com/trygvea/grails-class-diagram, and would like to override the config value classSelection as set here: https://github.com/trygvea/grails-class-diagram/blob/master/grails-app/conf/ClassDiagramConfig.groovy in my apps Config.groovy file.

None of the following seem to work:

grails.plugins.class-diagram.classDiagram.config.defaults.classSelection = "com.mypackage.*"
grails.plugins.class-diagram.config.preferences.defaults.classSelection = "com.mypackage.*"
grails.plugins.class-diagram.classDiagram.config.preferences.defaults.classSelection = "com.mypackage.*"

how do i access the correct namespace in order to override the value?

thanks!

Upvotes: 1

Views: 1412

Answers (2)

Ken Liu
Ken Liu

Reputation: 22914

The names of Config properties are arbitrary, they don't necessarily have to follow any specific pattern or convention like package name.

If you have only a single property to override you can use the "flattened" syntax:

classDiagram.preferences.defaults.classSelection = 'com.mypackage.*'

You can also declare Config properties using closure syntax (as in the example Config file) if you want to group several properties together:

classDiagram {
    preferences {
        defaults {
            classSelection = "com.mypackage.*"
            showAssociationNames = false
            showMethodReturnType = true
            showMethodSignature = false            
        }
    }
}

Note that the Grails plugin system doesn't automatically load *Config.groovy files from a plugin into an application's Config. A plugin developer can set up a plugin to merge a default *Config.groovy file into the application's Config, in which case usually the properties in an application's Config.groovy will override the Config properties supplied by a plugin.

Upvotes: 3

doelleri
doelleri

Reputation: 19682

Properties set in your Config.groovy will override a plugin's Config.groovy properties if they have the same name. You're adding a package for the properties, but that's not necessary. Use

classDiagram.preferences.defaults.classSelection = "com.mypackage.*"

Upvotes: 0

Related Questions