如何正确使用zipfileset创建ZIP文件? [英] How to create ZIP file properly using zipfileset?
本文介绍了如何正确使用zipfileset创建ZIP文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要来收集的Myproj目录也都 .MAP
文件从它的子目录,然后创建一个 L.zip
文件。
下面是我的code。
<目标名称=buildLFiles>
<拉链destfile =../../斌/ L.zip更新=真>
< zipfileset = CASESENSITIVE无DIR =../../../的Myproj包括=**** / *地图。/>
< /拉链>
< /目标与GT;
在这里问题是,我得到的所有 .MAP
文件,但它是明智的文件层次得到创建。
示例:
这是原来的文件结构:
MyProj文
| - 一个
| - B
| - x1.MAP
电流输出:
→
| - 一个
| - B
| - x1.MAP
需要的输出:
→
| - x1.MAP
解决方案
你可以做的是使用别的目录复制任务的扁平化
属性扁平化的结构,那么拉链该目录中。
<目标名称=buildLFiles>
<属性名=tmp.dirVALUE =../../斌/ TMP/>
<属性名=zip.fileVALUE =../../斌/ L.zip/>
<副本todir =$ {} tmp.dir扁平化=真>
<文件集DIR =../../../的Myproj>
<包括姓名=** / *地图。/>
< /文件集>
< /复制>
<拉链destfile =$ {} zip.file更新=真>
< zipfileset = CASESENSITIVE无DIR =$ {} tmp.dir包括=*地图。/>
< /拉链>
<删除DIR =$ {} tmp.dir/>
< /目标与GT;
I want to gather all .map
files from Myproj directory also from it's sub-directories, then create a L.zip
file.
Here is my code.
<target name="buildLFiles" >
<zip destfile="../../bin/L.zip" update="true" >
<zipfileset casesensitive="no" dir="../../../Myproj" includes= "****/*.MAP" />
</zip>
</target>
Problem here is, I am getting all .map
files but it is getting created in file hierarchy wise.
Example:
This is original file structure:
MyProj
|- a
|- b
| - x1.MAP
Current Output:
L
|- a
|- b
| - x1.MAP
Required output:
L
|- x1.MAP
解决方案
What you could do is flatten the structure using the copy task's flatten
attribute in another directory, then zip that directory.
<target name="buildLFiles">
<property name="tmp.dir" value="../../bin/TMP" />
<property name="zip.file" value="../../bin/L.zip" />
<copy todir="${tmp.dir}" flatten="true">
<fileset dir="../../../Myproj">
<include name="**/*.MAP" />
</fileset>
</copy>
<zip destfile="${zip.file}" update="true">
<zipfileset casesensitive="no" dir="${tmp.dir}" includes="*.MAP" />
</zip>
<delete dir="${tmp.dir}" />
</target>
这篇关于如何正确使用zipfileset创建ZIP文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文