|
Changing absolute paths to relative paths when unpacking zip files in Ant. |
|
Facts -
Other software technologies
|
|
Thursday, 05 November 2009 20:33 |
|
Files in zip archives should have relative paths instead of absolute paths. If the path is
absolute most unzip tools still interpret these paths as a relative path. However Ant (v1.7.1)
unzips files to their absolute paths mentioned in the zip file.
The following ant mapper fixes this behaviour. That is, it converts the absolute paths in the zip
file to relative paths.
<unzip src="srcFile" dest="destDirectory">
<globmapper from="/*" to="*"/>
</unzip>
I have not tested the mapper above, instead I have tested the same lines in groovy:
ant.unzip(src: "srcFile", dest: "destDirectory") {
globmapper(from: "/*", to: "*")
}
|