ANT复制过程中重命名文件 [英] Renaming files during ANT copy

查看:687
本文介绍了ANT复制过程中重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要复制文件的目录,并在这个过程中重命名其中的一些。
当我运行下面的脚本,没有副本。
如果我评论的水珠映射器下面的文件中,该文件被复制(不重命名)

感谢您的帮助。
詹姆斯

 <?XML版本=1.0&GT?;
<项目名称=创建项目结构默认为主>
  <目标名称=主描述=复制模板文件到项目文件夹>
    <回声>复制模板文件到项目文件夹和LT; /回声>
    <副本todir =$ {} project.dir冗长=真覆盖=真>
      <文件集DIR =$ {} shared.files /模板工程排除= /&GTSVN;
      &所述;映射器>
        < chainedmapper>
          <从=* PACKAGENAME *为=* $ {package.name} */&GT映射器类型=水珠;
          <映射器类型=水珠从=* GAMENAME *为=* $ {game.name} */>
          <映射器类型=身份/>
        < / chainedmapper>
      < /映射器>
    < /复制>
  < /目标与GT;
< /项目>


解决方案

使出了变通方法,使用移动,并通过Mnementh指示正确映射器类型。谢谢

 <?XML版本=1.0&GT?;
<项目名称=创建项目结构默认为主>
    <目标名称=主描述=复制模板文件到项目文件夹>
    <回声>复制模板文件到项目文件夹和LT; /回声>
    <副本todir =$ {} project.dir冗长=真覆盖=真>
        <文件集DIR =$ {} shared.files /模板工程排除= /&GTSVN;
    < /复制>
    <招todir =$ {} project.dir>
        <文件集DIR =$ {} project.dir/>
        &所述;映射器>
        <映射器类型=正则表达式
                从=PACKAGENAME(*)(*),以=\\ 1 $ {package.name} \\ 2/>
        <映射器类型=正则表达式
                从=GAMENAME(*)(*),以=\\ 1 $ {game.name} \\ 2/>
        < /映射器>
    < /移动>
    < /目标与GT;
< /项目>

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>

解决方案

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>

这篇关于ANT复制过程中重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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