ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: zip from zip with mappers
Date Tue, 20 Nov 2012 05:05:46 GMT
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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message