Is it somehow possible to access the properties specified in Config.groovy
inside the BuildConfig.groovy
?
I need to copy some bootstrap files during the packaging process and the target directory depends on the specified environment. Since I need to access those file during application bootstrap I'd like to define the path in the Config.groovy
and rather not duplicate it.
The only solution I've found was reading the
Config.groovy
by myself (as mentioned by Don). Here my two line solution:The usual way to access a property such as
bootstrap.path
defined inConfig.groovy
isI've haven't tried this from
BuildConfig.groovy
, but if it doesn't work, then I guess it's becauseConfig.groovy
hasn't been read whenBuildConfig.groovy
is executed. In that case, you'll need to read it yourself. The implementation ofConfigurationHolder
should show you how to do this.If when you say the packaging process you mean when generating the WAR file then I've been able to copy files to different places using Grails scripts/events. For example, I needed to copy one file to the WEB-INF/classes folder when generating the WAR so I created an Events.groovy file under the /scripts folder with the following content:
As you can see in the event you can have access to the environment.
If this is not what you meant, then just ignore my answer.
You can do this:
to retrieve the current environment.