Skip to content

Unzip specific zip file from nested zip file using ANT

I have a zip file ex. ‘’ that contains 2 more zip files within it – and I want to only extract contents of and leave untouched.

I did try out the below code snippet, but found no luck yet –

<unzip src="" dest="test_dir">
            <fileset dir="test_dir">
                <include name=""/>
                <exclude name=""/>

Please advise how this could be achieved.



From the unzip task’s documentation:

Only file system based resource collections are supported by Unjar/Unwar/Unzip, this includes fileset, filelist, path, and files.

This means you have to have a physical copy of somewhere on the file system.

So, there really is no choice other than doing it in two steps:

<tempfile property="a" suffix=".zip"/>
<copy tofile="${a}">
    <zipentry zipfile="" name=""/>

<unzip src="${a}" dest="test_dir"/>
<delete file="${a}"/>
8 People found this is helpful