通过命令行参数更改默认的Ant目标 [英] Change default ant target by command line argument
问题描述
我最近指派任务,使蚂蚁能够建立战争包不同的环境。我几乎除了一个功能完成。
蚂蚁由像 -Denv = DEV
接受一个 ENV
参数,并使用不同的配置文件,以使war包。但是,默认目标为启动
将构建,部署和启动Tomcat。我不想蚂蚁当我通过在 -Denv = PROD
ARG部署战争既不启动服务器。我只想蚂蚁构建ROOT.war。这是不够的。
我知道我可以只输入多了一个字来实现这一目标,但你知道我们都是懒惰。 :D
有谁知道如何根据命令行参数更改默认的目标是什么?
我的要求如下:
-
蚂蚁-Denv = DEV
将构建,部署和启动服务器 -
蚂蚁-Denv = PROD
将只建造ROOT.war
我建议你在所谓的DEV和PROD你的的build.xml
文件中定义目标然后调用Ant为:
蚂蚁DEV
或
蚂蚁PROD
如果你想坚持与您当前使用的系统属性来选择目标的方法,然后@克罗克的答案似乎是要走的路。 (但我没有看到任何的优势,这种做法虽然。)
I'm recently assigned a task to make ant be able to build war packages for different environments. I'm almost done except one feature.
The ant accepts an env
parameter by like -Denv=DEV
, and use different configuration files to make the war package. But the default target is start
which will build, deploy and start the tomcat. I don't want ant to deploy the war neither start the server when I pass in the -Denv=PROD
arg. I only want ant to build the ROOT.war. It's enough.
I know I can just type one more word to achieve this goal, but you know we are all lazy. :D
Does anyone know how to change the default target according to the command line argument? My requirements are as below:
ant -Denv=DEV
will build, deploy, and start the serverant -Denv=PROD
will only build the ROOT.war
I suggest that you define targets in your build.xml
file called "DEV" and "PROD" and then invoke Ant as:
ant DEV
or
ant PROD
If you want to stick with your current approach of using a system property to select the target, then @krock's answer seems to be the way to go. (But I don't see any advantage in that approach though.)
这篇关于通过命令行参数更改默认的Ant目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!