0

In a Maven project, I have a zip containing a directory, which I need the content from. I.e.

foo.zip
    somedir
         content

I don't know the name of somedir. But there's just this one dir.

How can I get content into some specific dir? (target)

4

1 回答 1

2

If you're using Ant 1.8.2 or newer, a <cutdirsmapper> strips a configured number of leading directories from each source file name:

<project name="ant-unzip-mapped-dir" default="run" basedir=".">
    <target name="run">
        <unzip src="foo.zip" dest="target">
            <cutdirsmapper dirs="1"/>
        </unzip>
    </target>
</project>

somedir/content becomes content in your example.

Source: Ant's documentation on cutdirs-mapper

于 2013-04-29T15:42:39.407 回答