开发者

Ant: simplest way to copy over a relative list of files

Using Ant, I want to copy a list of files from one project to another, where each project has the same directory structure. Is there a way to get the following to work?

<project name="WordSlug" default="pull" basedir=".">

  <description>
      WordSlug: pull needed files
  </description>

  <property name="prontiso_home" location="../../prontiso/trunk"/>

  <!-- I know this doesn't work, what's the missing piece? -->
  <target name="pull" description="Pull needed files">
      <copy todir="." overwrite="true">
        <resources>
          <file file="${prontiso_home}/application/views/scripts/error/error.phtml"/>
         开发者_开发知识库 <file file="${prontiso_home}/application/controllers/CacheController.php"/>
          <!-- etc. -->
        </resources>
      </copy>
  </target>

</project>

Success is deriving the paths automatically:

${prontiso_home}/application/views/scripts/error/error.phtml copied to ./application/views/scripts/error/error.phtml
${prontiso_home}/application/controllers/CacheController.php copied to ./application/controllers/CacheController.php

Thanks!


Try creating a fileset:

<copy todir="." overwrite="true">
    <fileset dir="${prontiso_home}/application/">
        <include name="views/scripts/error/error.phtml,controllers/CacheController.php"/>
    </fileset>
</copy>

Typically, however, you use fileset to define patterns of files to copy, such as "copy all PHP files in my application directory:

    <fileset dir="${prontiso_home}/application/">
        <include name="**/*.phtml,**/*.php"/>
    </fileset>


OP here. I have a working solution:

<project name="WordSlug" default="pull" basedir=".">

  <description>
      WordSlug: pull needed files
  </description>

  <property name="prontiso_home" location="../../prontiso/trunk"/>

  <target name="pull" description="Pull needed files">
      <copy todir="." overwrite="true" verbose="true">
        <fileset dir="${prontiso_home}">
          <or>
            <filename name="/application/views/scripts/error/error.phtml"/>
            <filename name="/application/controllers/CacheController.php"/>
          </or>
        </fileset>
      </copy>
  </target>

</project>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜