在 ANT 复制期间重命名文件
我想复制一个文件目录,并在此过程中重命名其中一些文件。 当我运行下面的脚本时,没有任何复制。 如果我在下面的文件中评论全局映射器,则会复制文件(不重命名)
感谢您的任何帮助。 詹姆士
<?xml version="1.0" ?>
<project name="Create project structure" default="main">
<target name="main" description="Copy template files to project folder">
<echo>Copying template files to project folder</echo>
<copy todir="${project.dir}" verbose="true" overwrite="true">
<fileset dir="${shared.files}/templateproject" excludes=".svn"/>
<mapper>
<chainedmapper>
<mapper type="glob" from="*PACKAGENAME*" to="*${package.name}*"/>
<mapper type="glob" from="*GAMENAME*" to="*${game.name}*"/>
<mapper type="identity"/>
</chainedmapper>
</mapper>
</copy>
</target>
</project>
I'd like to copy a directory of files, and rename some of them in the process.
When I run the script below, nothing copies.
If I comment the glob mappers in the file below, the files are copied (without the renaming)
Thanks for any help.
James
<?xml version="1.0" ?>
<project name="Create project structure" default="main">
<target name="main" description="Copy template files to project folder">
<echo>Copying template files to project folder</echo>
<copy todir="${project.dir}" verbose="true" overwrite="true">
<fileset dir="${shared.files}/templateproject" excludes=".svn"/>
<mapper>
<chainedmapper>
<mapper type="glob" from="*PACKAGENAME*" to="*${package.name}*"/>
<mapper type="glob" from="*GAMENAME*" to="*${game.name}*"/>
<mapper type="identity"/>
</chainedmapper>
</mapper>
</copy>
</target>
</project>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
采取了一种解决方法,使用“移动”和正确的映射器类型,如 Mnementh 所示。 谢谢
Resorted to a workaround, using "move", and the correct mapper type as indicated by Mnementh. Thanks
看来, glob-mapper 仅适用于一个 ' *'。 我会尝试 regexp-mapper:
It seems, that the glob-mapper works only with one '*'. I would try the regexp-mapper:
您的问题是您没有选择正确的映射器:
会将链中的信息从第一个映射器传递到最后一个映射器相反,
应该是使用,它将依次尝试所有映射器,直到有一个匹配参考:http://ant. apache.org/manual/Types/mapper.html
(相当老的问题,但我刚刚发现搜索几乎相同的问题:-))
Your problem is that you did not choose the right mapper:
<chainedmapper>
will pass information in chain from the first to the last mapperInstead,
<firstmatchmapper>
should be used, which will try all mappers in turn, until one matchesReference: http://ant.apache.org/manual/Types/mapper.html
(quite an old question, but I just found searching for almost the same problem :-))