Ant : Process the files in the subfolder using tasks

空扰寡人 提交于 2019-12-20 07:18:40

问题


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"/>

回答1:


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>


来源:https://stackoverflow.com/questions/5075017/ant-process-the-files-in-the-subfolder-using-tasks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!