Unzip the files to the directory in which they are located, with Ant

It should be simple, but I cannot find a way to do this. I need to extract any zip files in subdirectories of a directory into the same subdirectory using Ant. Files are transferred to the ant task as a set of wildcard files, for example. * /. Zipper.

For example, an ant script may have to process the file a / b / c / file.zip that contains file.xml, so I would like to use the unzip task to extract the file in a / b / c / file.xml, but it is not known in advance what directory structure will be, i.e. may be /b/c/file.zip or t / u / v / w / x / y / z / file.zip.

The unzip task requires a "dest" directory, but I don't know what the complete dest directory will be until the script is run. I also looked at mapper, but as far as I can see, this is only for the extracted files, I cannot reference the location of the zip file as part of the display.

Any help would be greatly appreciated.

Thanks Stef

+3
source share
1 answer

You must do this using the for task from the ant -contrib package (on top of the fileset) and the standard dirname task in the body of the loop. You will also want to use the "w40" -contrib "var" task to disable the property set by "dirname", or the next iteration of the loop will not get a new value.

http://ant-contrib.sourceforge.net/

+2
source

Source: https://habr.com/ru/post/1792268/


All Articles