I'd like to append the env name on each war i build automatically (grails [dev|test|prod] war
I tried to do the following in BuildConfig.groovy but nothing changed:
switch (grails.util.GrailsUtil.environment) {
case "development":
grails.project.war.file = "target/${appName}-dev-${appVersion}"
case "test":
grails.project.war.file = "target/${appName}-test-${appVersion}"
case "production":
grails.project.war.file = "target/${appName}-prod-${appVersion}"
}
Any thoughts? of course I can change it manually on the command line but i'd thought i'd do it a little cleaner if possible...
GrailsUtil.environment
is deprecated - use grails.util.Environment.current.name
instead.
This is failing because of a timing issue - GrailsUtil.environment
isn't set yet so none of the cases match. Even if they were you'd have a problem since you have no break statements - you need one for each case.
This works (although it uses the full name, e.g. 'production' or 'development'):
grails.project.war.file = "target/${appName}-${grails.util.Environment.current.name}-${appVersion}.war"
You can also do something like this:
grails.project.war.file = "target/${appName}${grails.util.Environment.current.name == 'development' ? '-dev' : ''}.war"
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