Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I unzip a specific folder?

How can I unzip a specific folder with Ant?

Specifically, I have downloaded apache-tomcat-6.0.29.zip which contains the folder "apache-tomcat-6.0.29". I want Ant to unzip everything under "apache-tomcat-6.0.29" but not include "apache-tomcat-6.0.29" in the top of hierarchy.

I've tried a bunch of things, but I can't seem to get it to work.

Here's my latest attempt:

<unzip dest="${release.dir}/image/tomcat" src="${tomcat.zip}">
    <patternset>
        <include name="apache-tomcat-6.0.29/*"/>
    </patternset>
</unzip>

Any ideas?

like image 303
sproketboy Avatar asked Oct 22 '10 14:10

sproketboy


1 Answers

You can use a mapper within the unzip task to change the paths written.

<unzip dest="${release.dir}/image/tomcat" src="${tomcat.zip}">
    <patternset>
        <include name="apache-tomcat-6.0.29/*"/>
    </patternset>
    <mapper>
        <globmapper from="apache-tomcat-6.0.29/*" to="*"/>
    </mapper>
</unzip>
like image 107
martin clayton Avatar answered Sep 20 '22 07:09

martin clayton