ANT如何在Ant 1.8中使用词法范围属性?

| 一旦设置变得不可写,我有脚本无法工作,因为属性
<target name=\"test\" >

    <fileset id=\"dir1\" dir=\"./dir1\"/>
    <fileset id=\"dir2\" dir=\"./dir2\"/>

    <pathconvert property=\"path.converted\" refid=\"dir1\"/>
    <echo message=\"${path.converted}\"/>
    <property name=\"path.converted\" value=\"set this property manually\"/>
    <echo>${path.converted}</echo>
    <pathconvert property=\"path.converted\" refid=\"dir2\"/>
    <echo message=\"${path.converted}\"/>
</target>
总是回声相同的结果,但是我希望回声是不同的 我在Apache Ant 1.8.0发行版中读到, 词汇范围内的本地属性, 即仅定义的属性 在目标,顺序块内或 类似的环境。这非常 在s内有用的地方 宏现在可以定义一个临时的 一旦 任务已完成。 如何使用它们?
已邀请:
我找到了解决方案。使用本地任务
<target name=\"direct\" depends=\"\">

    <fileset id=\"dir1\" dir=\"./dir1\"/>
    <fileset id=\"dir2\" dir=\"./dir2\"/>

    <!--<property name=\"path.converted\" value=\"0\"/>-->
    <local name=\"path.converted\"/>

    <pathconvert property=\"path.converted\" refid=\"dir1\"/>
    <echo message=\"${path.converted}\"/>
    <local name=\"path.converted\"/>
    <property name=\"path.converted\" value=\"0\"/>

    <echo>${path.converted}</echo>
    <local name=\"path.converted\"/>
    <pathconvert property=\"path.converted\" refid=\"dir2\"/>
    <echo message=\"${path.converted}\"/>

</target>
对于上面的示例,我将对path.converted使用不同的名称。 path.converted.1,path.converted.2等 如果您将创建一个macrodef,则一定要使用local任务将属性设置为local。

要回复问题请先登录注册