Ant:将相同的文件集复制到多个位置 - 续
我的问题是该线程的延续: Ant:将相同的文件集复制到多个位置
我是新人给地图绘制者。有人(carej?)可以分享一个使用映射器来执行此操作的示例吗?这就是我正在尝试的:
parent_folder |----child1_folder | |----files | |----config.file | |----data.txt |----child2_folder |----child3_folder . . . |----childn_folder
我没有使用 ant-contrib 的选项(抱歉...... ant 位置或任何 taskdesf 不在我的控制之下)。所以我不知道如何循环不确定数量的文件夹。
对我的限制:
- 我只知道 child1_folder 的名称(不知道其他子文件夹的名称)
- 其他子文件夹的数量不确定
- 我需要在每个子文件夹下创建
files
文件夹(通过另一个子文件夹)任务,如果不是复制)。
这是我正在尝试的(目前正在尝试单个文件,一旦开始工作,将使用额外的映射器进行扩展):
<copy todir="/tmp/parent_folder" verbose="true">
<fileset dir="/tmp/parent_folder">
<include name="*/files/config.file"/>
</fileset>
<mapper type="glob" from="*/files/config.file" to="*/files/config.file"/>
</copy>
它一直说 skipped - don't know how to handle it
后面跟着 <代码>未找到来源。。
提前致谢, Parag Doke
另一个(可能?)相关问题: 使用映射器和文件集将文件复制到不同的子目录中?
My question is in continuation of this thread:
Ant: copy the same fileset to multiple places
I am new to mappers. Can someone (carej?) kindly share an example of using the mapper to do this ? Here is what I am trying for:
parent_folder |----child1_folder | |----files | |----config.file | |----data.txt |----child2_folder |----child3_folder . . . |----childn_folder
I don't have the option to use ant-contrib (sorry ... the ant location or any taskdesf isn't under my control). So I don't know how to loop over the uncertain number of folders.
Restrictions on me:
- I only know the name of child1_folder (don't know names of the other children)
- Number of other children is uncertain
- I am expected to create the
files
folder under each child folder (via another task, if not copy).
Here is what I was trying for (currently trying for a single file, will extend with additional mappers once this starts to work):
<copy todir="/tmp/parent_folder" verbose="true">
<fileset dir="/tmp/parent_folder">
<include name="*/files/config.file"/>
</fileset>
<mapper type="glob" from="*/files/config.file" to="*/files/config.file"/>
</copy>
It keeps saying skipped - don't know how to handle it
followed by No sources found.
.
Thanks in advance,
Parag Doke
Another (possibly?) related question:
Using mapper & fileset to copy files into a different subdirectory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种方法的示例。主要功能是在复制任务中使用
enablemultiplemappings
以及使用scriptmapper
来处理目标目录的迭代。映射器链用于使提供给脚本映射器的源只是要复制的文件相对于目标目录的路径。自版本 1.6 以来,Ant 中已包含复制任务中的多个映射。
Here's an example of one way. The key features are the use of
enablemultiplemappings
in the copy task, and ascriptmapper
to deal with iterating over the target directories. A mapper chain is used to make the source that is provided to the scriptmapper be just the path of the file to be copied relative to the target directory.Mulitple mappings in the copy task have been in Ant since version 1.6.