Scripting ANT如何使用Ant1.8中的词汇范围属性?
我的脚本不起作用,因为一旦设置为不可写的属性Scripting ANT如何使用Ant1.8中的词汇范围属性?,scripting,ant,Scripting,Ant,我的脚本不起作用,因为一旦设置为不可写的属性 <target name="test" > <fileset id="dir1" dir="./dir1"/> <fileset id="dir2" dir="./dir2"/> <pathconvert property="path.converted" refid="dir1"/> <echo message="${path.converted}"/>
<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>
${path.converted}
总是回显相同的结果,但我想回显是不同的
我在ApacheAnt1.8.0版本中读到
词汇范围的局部属性,
i、 e.仅定义的属性
在目标、顺序块或
类似的环境。这是非常重要的
在s的内部非常有用
宏现在可以定义一个临时
一旦死亡就会消失的财产
任务已经完成
如何使用它们?我找到了解决办法。使用
${path.converted}
对于上面的示例,我只需对path.converted使用不同的名称即可。path.converted.1、path.converted.2等
如果您想创建一个宏定义,您肯定应该使用local任务将属性设置为local。stackoverflow消息:您可以在2天内接受自己的答案
<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>