Ant属性bug

时间:2012-10-29 19:57:38

标签: ant

我有两种部署配置。 每个配置存储在其属性文件中。 dev.properties中的开发配置:

deploy.wowza.domain=DEV_IP_ADDRESS

prod.properties中的prod配置:

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]

1 个答案:

答案 0 :(得分:1)

问题是因为另一个build.xml在复制之前加载属性文件