Grails基于环境战争文件名 [英] Grails war filename based on environment

查看:82
本文介绍了Grails基于环境战争文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在自动构建的每场战争中追加env名称(grails [dev | test | prod] war



我试图在BuildConfig.groovy,但没有改变:

$ p $ switch $($ grails.util.GrailsUtil.environment){

casedevelopment:
grails.project.war.file =target / $ {appName} -dev - $ {appVersion}
casetest:
grails.project.war .file =target / $ {appName} -test - $ {appVersion}
caseproduction:
grails.project.war.file =target / $ {appName} -prod- $ {appVersion}

有什么想法?当然我可以在命令行,但我想我会尽可能清理一下,如果可能的话... ...

> GrailsUtil.environment 已被弃用 - 请使用 grails.util.Environment.current.name

由于计时问题 - GrailsUtil.e,这是失败的nvironment 尚未设置,因此没有任何匹配。即使他们是你有问题,因为你没有断言 - 你需要每个案件一个。



这工作(虽然它使用全名,例如'生产'或'开发'):

  grails.project.war.file =target / $ {appName}  -  $ {grails.util.Environment.current.name}  -  $ {appVersion} .war


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"

这篇关于Grails基于环境战争文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆