我有两种部署配置。每个配置存储在其属性文件中。dev.properties 中的开发配置:
deploy.wowza.domain=DEV_IP_ADDRESS
prod.properties 中的产品配置:
deploy.wowza.domain=PROD_IP_ADDRESS
我有 build.xml
<?xml version="1.0"?>
<project name="MAIN" default="dev" basedir=".">
<target name="dev">
<property file="${java.root.dir}/ant/dev.properties"/>
<echo>
DEV
${deploy.wowza.domain}
</echo>
<sleep seconds="1"/>
</target>
<target name="prod">
<property file="${java.root.dir}/ant/prod.properties"/>
<echo>
PROD
${deploy.wowza.domain}
</echo>
<antcall target="deploy"/>
</target>
</project>
如果我运行 prod 或 dev 任务,它只会在第二次运行时显示正确的属性值
D:\Dropbox\camwithme>ant prod
Buildfile: D:\Dropbox\camwithme\build.xml
prod:
[copy] Copying 1 file to D:\Dropbox\camwithme\wowza_cam\ant
[echo]
[echo] PROD
[echo] PROD_IP_ADDRESS
[echo]
BUILD SUCCESSFUL
Total time: 0 seconds
D:\Dropbox\camwithme>ant dev
Buildfile: D:\Dropbox\camwithme\build.xml
dev:
[copy] Copying 1 file to D:\Dropbox\camwithme\wowza_cam\ant
[echo]
[echo] DEV
[echo] PROD_IP_ADDRESS !!! Should be dev ip here !!!
[echo]
BUILD SUCCESSFUL
Total time: 0 seconds
D:\Dropbox\camwithme>ant prod
Buildfile: D:\Dropbox\camwithme\build.xml
prod:
[copy] Copying 1 file to D:\Dropbox\camwithme\wowza_cam\ant
[echo]
[echo] PROD
[echo] DEV_IP_ADDRESS
[echo]