开发者

Grails war filename based on environment

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.Gr开发者_运维知识库ailsUtil.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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜