在BuildConfig访问设置 [英] Access settings in BuildConfig
问题描述
是它在某种程度上可以访问在 Config.groovy中指定的属性
中的 BuildConfig.groovy
?
Is it somehow possible to access the properties specified in Config.groovy
inside the BuildConfig.groovy
?
我需要在包装过程中的一些引导文件复制和目标目录取决于指定的环境。因为我需要访问应用程序中的引导文件,我想定义在 Config.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.
推荐答案
通常的方式来访问的属性,如 bootstrap.path
在定义Config.groovy中
是
The usual way to access a property such as bootstrap.path
defined in Config.groovy
is
def bootStrapPath = org.codehaus.groovy.grails.commons.ConfigurationHolder.config.bootstrap.path
我没有从 BuildConfig.groovy
尝试这样做,但如果它不工作的话,我想这是因为配置。常规
在执行 BuildConfig.groovy
尚未阅读。在这种情况下,你需要自己阅读。 ConfigurationHolder
的实施应告诉你如何做到这一点。
I've haven't tried this from BuildConfig.groovy
, but if it doesn't work, then I guess it's because Config.groovy
hasn't been read when BuildConfig.groovy
is executed. In that case, you'll need to read it yourself. The implementation of ConfigurationHolder
should show you how to do this.
这篇关于在BuildConfig访问设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!