Renaming files during ANT copy

烈酒焚心 提交于 2019-11-30 06:48:53
tarling

Resorted to a workaround, using "move", and the correct mapper type as indicated by Mnementh. Thanks

<?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" />
    </copy>
    <move todir="${project.dir}">
        <fileset dir="${project.dir}" />
        <mapper>
        <mapper type="regexp"
                from="(.*)PACKAGENAME(.*)" to="\1${package.name}\2" />
        <mapper type="regexp"
                from="(.*)GAMENAME(.*)" to="\1${game.name}\2" />
        </mapper>
    </move>
    </target>
</project>
Mnementh

It seems, that the glob-mapper works only with one '*'. I would try the regexp-mapper:

<mapper type="regexp" from="(.*)PACKAGENAME(.*)" to="\1${package.name}\2"/>
<mapper type="regexp" from="(.*)GAMENAME(.*)" to="\1${game.name}\2"/>

Your problem is that you did not choose the right mapper: <chainedmapper> will pass information in chain from the first to the last mapper

Instead, <firstmatchmapper> should be used, which will try all mappers in turn, until one matches

Reference: http://ant.apache.org/manual/Types/mapper.html

(quite an old question, but I just found searching for almost the same problem :-))

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!