On 2012-11-19, Patrick Martin wrote:

> I have a situation where I need to create an archive (zip) from an other
> one, but transforming some path inside. I want to avoid using a temporary
> folder structure as the input files contains a huge amount of entries
> (about 125000...) and this generates quite a lot of I/Os.

> I was thinking of using <zip> and <zipfileset>. However, as <zip> does not
> support <mapper>, it is not possible directly.

> So I thought of using the <mappedresources> resource collection:
> <zip destfile="dest.zip">
> <mappedresources enablemultiplemappings="true">
> <zipfileset src="src.zip" includes="**" />
> <firstmatchmapper> <mapper type="glob" from="fromfolder\*" to="tofolder\*"
> /> <identitymapper /> </firstmatchmapper>
> </mappedresources>
> </zip>

> The mapping is done quite fast but then zip is reeaaally slow (can be seen
> when running in verbose mode).

Yes, this is a known problem with the way Ant deals with zipfileset.

> My guess is that Ant will look for each resource individually and thus
> scan the source zip each time.

It's even worse.  The ZIP file will be reopened and the central
directory re-parsed every time an entry is read.  This is avoided by
special code inside the zip task when the zipfileset is nested directly
into the task.

> Is there any other possibility to achieve zip to zip transfer with mapping
> / transformation (and filtering with include/exclude patterns) ?
> Or is there any way to add <mapper> support in <zip> ?

Filtering should work by using zipfileset directly.  As for mapping, I'm
afraid there is no real solution - apart from coding the ZIP creation
directly in Java.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to