Reputation: 56944
I have a Grails app (myapp
) that uses a custom plugin (grails-fizz
). In myapp
's Config.groovy
I have the following var defined:
logfile = "/opt/myapp/logs/myapp.log"
I then pull in grails-fizz
as a plugin inside the app's BuildConfig.groovy
file. In grails-fizz
's FizzGrailsPlugin.groovy
, I try to use that value:
def doWithApplicationContext = { ctx ->
println("The logfile is ${logfile}.")
}
When this runs I get the following error:
Error initializing the application: No such property: logfile for class: FizzGrailsPlugin
It seems that the plugin doesn't have scope/visibility over this var? What's the solution?
Upvotes: 0
Views: 398
Reputation: 122414
From the documentation
Every plugin has an implicit
application
variable which is an instance of the GrailsApplication interface.
So you can use application.config
to access the configuration.
Upvotes: 1
Reputation: 24776
You can access configuration values through the configuration object.
def doWithApplicationContext = { ctx ->
def config = ctx.config
println println "The logfile is ${config.logfile}."
}
Upvotes: 1