2

在 ant 解压缩任务之后,如何从文件层次结构中排除存档名称?

例如,一旦 ant 在文件夹中运行解压缩任务C:\temp,我想要存档存档中的所有文件,但我得到了C:\temp\t\file.tmp.

我可以有效地排除存档中的基本目录吗?

4

3 回答 3

4

使用映射器指定文件在目标目录中的外观:

<unzip src="t.zip" dest="temp">
    <globmapper from="t/*" to="*"/>
</unzip>
于 2010-07-03T20:53:39.517 回答
2

现在更好的解决方案是cutdirsmapper

<unzip src="t.zip" dest="temp">
    <cutdirsmapper dirs="1"/>
</unzip>
于 2012-09-25T19:02:20.290 回答
1

我用:

<mapper type="flatten" />   


另请参阅https://www.safaribooksonline.com/library/view/ant-the-definitive/0596001843/ch04s10.html

扁平化映射器从文件名中删除所有路径信息。

例如在 build.xml 中:

<target name="extract-xsd">
    <unzip src="./cache/nl.packagename.example/xx/jars/somepackage.jar" dest="repository">
        <mapper type="flatten" />
        <patternset>
            <include name="**/Example.xsd"/>
            <include name="**/Example.wsdl"/>
        </patternset>
    </unzip>
</target>

因此,Example.xsd 和 Example.wsdl 直接放在存储库文件夹中。

于 2016-02-05T13:48:15.727 回答