如何通过建立在Ant中映射指定的目录 [英] How to create directories specified by a mapper in Ant

查看:162
本文介绍了如何通过建立在Ant中映射指定的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个文件集

<fileset id="myFiles" dir=".">
    <include name="**/*.file"/>
</fileset>

如何创建一个子目录在集合中的每个文件,不带扩展名的文件名命名的?

How do I create a sub-directory at each file in the set, named after the filename without the extension?

例如,给定文件folderA / X.file和folderA / FolderB中/ Y.file,我要创建目录folderA / X和folderA / FolderB中/ Y

For example, given the files folderA/X.file and folderA/folderB/Y.file, I want to create the directories folderA/X and folderA/folderB/Y

推荐答案

蚂蚁触摸任务支持创建文件,父显示目录和文件名映射,因此可以用来实现这一点:

The ant touch task supports creating files, parent dirs and filename mapping, so can be used to achieve this:

  <target name="mkdirs">
    <touch mkdirs="true">
      <fileset dir="the_dir"/>
      <mapper type="glob" from="*.file" to="the_dir/*/.tmp" />
    </touch>
    <delete>
      <fileset dir="the_dir" includes="**/.tmp"/>
    </delete>
  </target>

这将创建目标迪尔斯临时文件(创建迪尔斯如果不存在),然后删除临时文件离开你想显示目录。

This creates temporary files in target dirs (creating the dirs if the don't exist) then deletes the temporary files leaving the dirs you wanted.

这篇关于如何通过建立在Ant中映射指定的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆