English 中文(简体)
如何用不同的参数来管理习惯任务?
原标题:How to run a custom task few times with different parameters?
  • 时间:2011-11-23 04:41:09
  •  标签:
  • ant

我正试图执行“MyTarget”的目标,并发现一个错误:“未支持的内容重复”。 也许Macrodef不是做这项工作的途径。 是否有其他办法把任务交给另一个具有不同参数的目标/目标?

<macrodef name="dotask">
    <attribute name="platform" description="" />
    <attribute name="config" description="" />
    <element name="task2" optional="true" />
    <sequential>
        <task2 />
    </sequential>
</macrodef>

<macrodef name="buildsuite2">
    <element name="task" optional="true" />
    <sequential>
        <dotask platform="win32" config="debug">
            <task />
        </dotask>   
        <dotask platform="win32" config="release">
            <task />
        </dotask>
    </sequential>
</macrodef>

    <target name="MyTarget">
        <buildsuite2>
            <task>
                <echo>${platform} ${config}</echo>
            </task>
        </buildsuite2>
    </target>
问题回答

如何用不同的参数来管理习惯任务?

是的,可在 rel=“nofollow”>的任务中找到。

The sample:

<target name="method_impl">
    <echo message="${firstParam}"/>
    <echo message="${secondParam}"/>
</target>

<target name="test_calling_twice">
    <echo message="First time call"/>
    <antcall target="method_impl">
        <param name="firstParam" value="fP1"/>
        <param name="secondParam" value="sP1"/>
    </antcall>

    <echo message="Second time call"/>
    <antcall target="method_impl">
        <param name="firstParam" value="fP2"/>
        <param name="secondParam" value="sP2"/>
    </antcall>
</target>

产出如下:

First time call
fP1
sP1
Second time call
fP2
sP2





相关问题
i want to continously run my java threads

I am running my java application where i have used threads... i am running this application using ant command on the terminal.. But when i close my terminal or press ctrl+c,then java program which was ...

Subant targets instead of ant

I m having a problem with subant and have no ideas any more. Can anyone help? Using Ant to replace some strings for other (i.e Productname and Version for "Foo" and "1.2") I used ...

java ant buildfile for project with dependencies

I am new to ant, but am trying to create an ant script that builds my current proeject with another project as a dependency. I have the ant script building my current project, but am unsure how to add ...

Building Apache Hive - impossible to resolve dependencies

I am trying out the Apache Hive as per http://wiki.apache.org/hadoop/Hive/GettingStarted and am getting this error from Ivy: Downloaded file size doesn t match expected Content Length for http://...

Ivy, ant and start scripts

I have a project that uses ant to build and ivy for dependencies. I would like to generate the start scripts for my project, with the classpath, based on the dependencies configured in Ivy, ...

热门标签