代码改变世界

Ant: macrodef

2020-07-30 21:04  jetwill  阅读(85)  评论(0编辑  收藏  举报
<macrodef name="tokenReplace">
    <attribute name="subapp"/>
    <attribute name="targetFile"/>
    <sequential>
        <echo>Replacing tokens in file @{targetFile}</echo>
        <replace file="@{targetFile}" encoding="utf-8">
            <replacefilter token="@subapp@" value="${subapp}"/>
        </replace>
        <exec executable="chown">
            <arg value="uc9usr:tcgroup"/>
            <arg value="@{targetFile}"/>
        </exec>
    </sequential>
</macrodef>
 ...
<target name="xxx">
    ...
    <tokenReplace subapp="ifmmanage" targetFile="${tc.app.webroot.ifmmanage}/ifmmanage.xml"/>
</target>

https://ant.apache.org/manual/Tasks/replace.html