How can I unzip a specific folder?

2019-04-04 06:16发布

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?

3条回答
祖国的老花朵
2楼-- · 2019-04-04 06:55
<unzip dest="${release.dir}/image/tomcat" src="${tomcat.zip}">
    <patternset>
        <!-- add another star -->
        <include name="apache-tomcat-6.0.29/**"/>
    </patternset>
</unzip>
查看更多
淡お忘
3楼-- · 2019-04-04 07:09

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>
查看更多
叼着烟拽天下
4楼-- · 2019-04-04 07:10

The following works as long that there is a single directory in the tomcat archive.

<untar src="${release.dir}" dest="${tomcat.tar.gz}" compression="gzip">
  <cutdirsmapper dirs="1" />
</untar>
查看更多
登录 后发表回答