开发者

Using Ant to delete a file based on existence of another file

开发者 https://www.devze.com 2023-03-08 05:12 出处:网络
I need to write an ant task to selectively delete files. In a directory, I have the following jars: acme.jar

I need to write an ant task to selectively delete files.

In a directory, I have the following jars:

acme.jar acme-201105251330.jar

I want to delete acme.jar because acme-*.jar exists.

Here's what I've tried:

<target name="-check-use-file">
<available pr开发者_如何学Gooperty="file.exists"> 
<filepath> <fileset dir="."> 
  <include name="./test-*.jar"/> </fileset> 
</filepath> 
</available> 
</target> 
<target name="use-file" depends="-check-use-file" if="file.exists"> 
<!-- do something requiring that file... --> 
</target>

Thanks


Have a look at If/Unless Attributes, examples given there seem to be exactly what you are looking for.

0

精彩评论

暂无评论...
验证码 换一张
取 消