Reputation: 46796
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
)
Upvotes: 0
Views: 186
Reputation: 7041
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
Upvotes: 2