我的目标是将一组由模式指定的文件复制到目标目录。源目录中的文件可以有子目录。
我试过了:
cp_r(Dir.glob('**/*.html'), @target_dir):
和
cp_r(FileList['**/*.html'], @target_dir):
但两者都不起作用。
它仅在我执行以下操作时才有效:
cp_r(Dir['.'], @target_dir):
但我只需要复制 *.html 文件而不是其他任何东西。
我需要什么
cp --parents
命令确实
使用现有的 Ruby/Rake 方法有什么建议吗?
更新看起来用 Ant 更容易做的事情,用 Ruby/Rake 堆栈是不可能的——可能我需要研究别的东西。我不想编写自定义代码以使其在 Ruby 中工作。我只是认为 Ruby/Rake 是合适的解决方案。
更新 2这就是我使用 Ant 的方式
<target name="buildeweb" description="Builds web site" depends="clean">
<mkdir dir="${build.dir.web}" />
<copy todir="${build.dir.web}" verbose="true">
<fileset dir="${source.dir.web}">
<include name="**/*.html" />
<include name="**/*.htm" />
</fileset>
</copy>
<chmod perm="a+x">
<fileset dir="${build.dir.web}">
<include name="**/*.html" />
<include name="**/*.htm" />
</fileset>
</chmod>
</target>