Ant : Process the files in the subfolder using tasks
I have a folder structure as follows
+ [BASE]
+++ [DIR 1]
++++++ File.zip
+++ [DIR 2]
++++++ File.zip
....
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"/>
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>
精彩评论