Domanda

This should be simple but I can't find a way to do it. I need to extract any zip files in sub directories of a directory to the same sub directory using Ant. The files are passed to the ant task as a fileset with wildcards e.g. */.zip.

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

The unzip task requires the "dest" directory but I don't know what the full dest directory will be until the script is running. I also considered the mapper but as far as I can see this is just for the extracted files I can't reference the zip file location as part of the mapping.

Any help would be greatly appreciated.

Thanks, Stef

È stato utile?

Soluzione

You should be able to do this with the "for" task from the ant-contrib package (over a fileset) and standard "dirname" task in the body of the loop. You will also want to use the ant-contrib "var" task to unset the property set by "dirname" or the next loop iteration will not get the new value.

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top