开发者

Ant : Process the files in the subfolder using tasks

开发者 https://www.devze.com 2023-02-12 06:49 出处:网络
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 D

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>
0

精彩评论

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