0

我想实现一个<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>

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

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

但是没有办法做一个<attribute/>可选的。

4

0 回答 0