使用 Ant 将文件解压到它们所在的目录中
这应该很简单,但我找不到办法做到这一点。我需要使用 Ant 将目录子目录中的所有 zip 文件提取到同一子目录。文件作为带有通配符的文件集传递给 ant 任务,例如 */.zip。
例如,ant脚本可能必须处理包含file.xml的文件a/b/c/file.zip,所以我想使用unzip任务将文件解压到a/b/c/file.xml,但是事先不知道目录结构是什么,即可以是 a/b/c/file.zip 或 t/u/v/w/x/y/z/file.zip。
解压缩任务需要“dest”目录,但在脚本运行之前我不知道完整的 dest 目录是什么。我还考虑了映射器,但据我所知,这仅适用于提取的文件,我无法引用 zip 文件位置作为映射的一部分。
任何帮助将不胜感激。
谢谢, 斯特夫
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用 ant-contrib 包中的“for”任务(通过文件集)和循环体中的标准“dirname”任务来完成此操作。您还需要使用 ant-contrib“var”任务来取消设置“dirname”设置的属性,否则下一次循环迭代将无法获取新值。
http://ant-contrib.sourceforge.net/
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/