1

Can someone give me an example of how to use Phing's UpToDateTask with a mapper? I can't figure it out and I can't find any examples on the net.

Here's what I am trying to achieve. I have a bunch of SCSS files that I convert to CSS using the ExecTask and Ruby's SASS parser. But, I only want to regenerate the CSS files if any of the source files have changed.

The source SCSS files are in app/assets/css and the compiled files are placed in app/webroot/css. How can I use the UpToDateTask to test if any of the files in app/assets/css are newer than any of the files in app/webroot/css?

Note that the SASS comilation does not have a 1-to-1 filename mapping to CSS files. There could be a dozen SCSS files that in the end get compiled into 3-4 CSS files. I know I could simply hard-code those CSS files into my build.xml but I would like to create a more generic, re-usable build target.

Thanks in advance!

4

2 回答 2

1

如果您事先知道将存在哪些结果文件,则可以使用身份映射器检查每个源文件是否比单个结果文件新。对每个结果文件执行此操作,您就会知道是否有更改。

于 2011-08-01T09:09:45.470 回答
0

我通过反复试验为自己弄清楚了。我上面描述的场景(测试源目录中的任何文件是否比目标目录中的任何文件都新)无法在uptodate任务中使用映射器来实现。该uptodate任务只需遍历fileset,使用 转换任何文件名mapper,然后将该文件与原始文件进行比较。

目前我正在使用一个文件集,其中包含所有不以下划线开头的文件(SASS 包括)和一个简单的映射器,它只是 glob*.scss*.css. 它有效,但并不完美。当只有一个包含文件发生更改(以下划线开头的文件)时,Phing 将不会检测到任何更改并跳过重建 CSS 资产。

于 2011-08-01T08:26:24.780 回答