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.
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:
// Copy liquibase changelog.xml to classpath folder
eventWarStart = {warName ->
if (grailsEnv == "production") {
println "Copying database migration files to classpath!"
Ant.copy(toFile: "${classesDirPath}/changelog.xml", filtering: true, overwrite: true) {
fileset(file: "${basedir}/grails-app/migrations/changelog.xml")
}
Ant.copy(toDir: "${classesDirPath}/releases/", filtering: true, overwrite: true) {
fileset(dir: "${basedir}/grails-app/migrations/releases/")
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With