Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Renaming files during ANT copy

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>
like image 403
tarling Avatar asked Aug 07 '09 10:08

tarling


People also ask

How do I rename a .cpp file in Visual Studio?

Either use your operating system's file explorer (on windows press windows button + e), as noted by drescherjm, or right click the file you want to change the name of inside of visual studio (there should be a box called solution explorer), and click "rename".

What is the method of rename () a file?

Find and select the file, then select File > Rename. Type the new name and press Enter.


1 Answers

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>
like image 86
tarling Avatar answered Sep 25 '22 12:09

tarling