如何使财产ANT作为可变 [英] How to make a property in ANT as mutable

查看:131
本文介绍了如何使财产ANT作为可变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用蚂蚁条件任务来检查文件是否存在以及存在的目录及以下就是我的code

I'm using ant condition task to check a file existence and directory existence and below is my code

<project name="makeitmutable" basedir="." default="main">
  <target name="main">
     <condition property="folderexists?" value="Yeah" else="Nope">
       <and>
          <available file="folderexistance" type="dir"/>
          <available file="a.zip" type="file"/>
      </and>
     </condition>
     <echo>before deleting "folderexistance" folder  property folderexists?=${folderexists?}</echo>
     <delete dir="folderexistance"/>
     <!--after delete-->
      <condition property="folderexists?" value="Yeah" else="Nope">
       <and>
          <available file="folderexistance" type="dir"/>
          <available file="a.zip" type="file"/>
      </and>
     </condition>
     <!--how to make below line to print Nope ?-->
   <echo>After deleting "folderexistance" folder  property folderexists?=${folderexists?}</echo>
  </target>
</project>

属性folderexists我的产值?甚至删除该目录后仍保持不变,即..,都能跟得上两次

My output value of the property folderexists? remains same even after deleting the directory,i.e.., Nope two times

我知道蚂蚁的属性是不可改变的,一旦设定,不能更改,而且该解决方案的替代是我们可以使用

I knew that ant properties are immutable once set cannot be changed,and also an alternative to this solution is we can use

<antcall>

任务,并呼吁主要目标。

task and call the main target.

有没有一种方法,使财产该指标范围内可变在上述情况下,我在寻找其他的可能性,以解决这个问题,什么是良好的编程习惯这种类型的问题。

Is there a way to make the property mutable within that target as in the above scenario,I'm looking for other possibilities to resolve this,what's the better programming practice for this type of problem

推荐答案

正如你所说的,属性是不可改变的。唯一的其他选择是使用 VAR 从蚂蚁的contrib任务。

As you said, properties are immutable. The only other option is to use the var task from ant-contrib.

从文档报价:一般情况下,使用这一任务的是气馁,标准的Ant属性应尽可能使用 话虽如此,在现实生活中我用这一个许多。

这说了很多,太多; - )

which says a lot, too ;-)

这篇关于如何使财产ANT作为可变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆