开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜