有没有办法在蚂蚁中“重载”两个macrodef?

时间:2015-02-11 12:56:26

标签: ant overloading macrodef

我想实现一个可以通过两种方式调用的<macrodef/>:使用单个文件参数或使用<fileset/>

<macrodef name="sqlplus">
    <attribute name="file"/>
    <sequential>
        <!-- there be dragons, here -->
    </sequential>
</macrodef>

<macrodef name="sqlplus">
    <element name="files"/>
    <sequential>
        <for param="file">
            <path>
                <files/>
            </path>
            <sequential>
                <!-- call the other macro -->
                <sqlplus file="@{file}"/>
            </sequential>
        </for>
    </sequential>
</macrodef>

这似乎不起作用。有什么技巧可以用来实现“准” - 过载吗?或者我是否必须重命名其中一个macrodef?我知道我可以写这个,并检查参数是否已设置(例如使用ant-contrib):

<macrodef name="sqlplus">
    <attribute name="file"/>
    <element name="files" optional="yes"/>
    <!-- ... -->
</macrodef>

但是没有办法让<attribute/>可选。

0 个答案:

没有答案
相关问题