开发者

How to get archive name while unzipping

开发者 https://www.devze.com 2023-02-05 00:32 出处:网络
I am using ant unzip task to get contents of a archive file. Is there a possibility to also save the name of that archive somehow.

I am using ant unzip task to get contents of a archive file.

Is there a possibility to also save the name of that archive somehow.

Below is the code I am using to unzip an archive.

    <unzip dest="${import.dir}">
        <fileset dir="${tmp.dir}"&g开发者_C百科t;
            <include name="**/*.zip"/>
        </fileset>   
    </unzip>

Regards, Satya


You could use an embedded groovy script

<target name="unzip">
    <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>

    <fileset id="zips" dir="${tmp.dir}" includes="**/*.zip"/>

    <groovy>
        project.references.zips.each { file ->
            ant.echo(message:"message goes here", file:"build.log", append:true)
            ant.unzip(src:file, dest:properties["import.dir"])
        }
    </groovy>
</target>

Groovy task is documented here

0

精彩评论

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