我起初是想解决同一个tomcat下运行两个相同项目的问题,这个需要web.xml里的webAppRootKey进行区分。
一个为webApp.root,另一个则改为xxx.root
但是需要在编译前就改为,否则运行报错
<target name="init" depends="clean" description="初始化">
    ......
    <echo>初始化工作结束!</echo>
    ......
    <condition property="runInitAppTarget">
        <equals arg1="${isDev}" arg2="true" />
    </condition>
    <antcall target="initApp" />
</target>
<target name="initApp" if="runInitAppTarget">
    <replace file="${web.WEB-INF}/web.xml"
             token="webApp.root"
             value="${webapp.root.value}" />
    <echo>replace success</echo>
</target>

在run build时,加上Ant properties: 

isDev:true / false 即可决定是否执行initApp