Ant :使用任务处理子文件夹中的文件 [英] Ant : Process the files in the subfolder using tasks
本文介绍了Ant :使用任务处理子文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的文件夹结构如下
+ [BASE]
+++ [DIR 1]
++++++ File.zip
+++ [DIR 2]
++++++ File.zip
....
我在 BASE 中有一个 build.xml.我需要有一个任务,我可以解压缩每个 DIR*
中的 File.zip
.我需要这样才能处理添加的新 DIR.
I have a build.xml in BASE. I need to have a task where I can unzip the File.zip
in each DIR*
. I needed it to be such that a new DIR added also should be handled.
为了获取目录名称,我尝试了以下操作,但不知道如何进一步
I tried the following, in order to get the dir names but don't know how to proceed further
<dirset id="contents" dir="." />
<property name="prop.contents" refid="contents"/>
推荐答案
您可以尝试嵌入式 groovy 脚本.像这样:
You could try an embedded groovy script. Something like this:
<target name="unzip">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<fileset id="zips" dir="." includes="**/*.zip"/>
<groovy>
project.references.zips.each { fileResource ->
def file = new File(fileResource.toString())
ant.unzip(src:file, dest:file.parent)
}
</groovy>
</target>
这篇关于Ant :使用任务处理子文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文