0

我有两种部署配置。每个配置存储在其属性文件中。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]
4

1 回答 1

1

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

于 2012-10-30T06:29:58.783 回答