I've been trying to write an Ant task to "compile" Sass scripts in my project using the apply task but I kept getting a "No such file or directory" error. I thought it might have been caused by spaces in the buildpath so I went through the trouble of moving the project only to find that Ant seems to omitting the fileset's root directory when it returns the path. This is what the target looks like:
<target name="sass-compile" depends="properties">
<apply executable="sass">
<srcfile />
<targetfile />
<fileset dir="${project.src.dir}" includes="**/*.scss" />
<globmapper from="*.scss" to="*.css" />
</apply>
</target>
To help troubleshoot, I switched the executable from sass to echo and I noticed that the mapper is transforming paths like this...
/Users/me/Documents/Programming/workspace/Project/src/java/com/proj/web/page/template/Template.scss
...into this...
/Users/me/Documents/Programming/workspace/Project/java/com/proj/web/page/template/Template.css
Notice that the src directory is missing from the target file path. Am I seeing a bug here or is this somehow expected? I would love to know what's going on here. I have also tried using a regexpmapper, and a filtermapper with replacestring. The result is the same.
I'm running Ant 1.7.1, which comes bundled with Eclipse Helios, which I'm running on a Mac. I also tried Ant 1.8 on both Mac and Linux. Nothing works. Does anyone have any ideas?
It's normal behaviour. The mappers use relative paths, not absolute. The path will be relative to the working (probably base) directory, which in your case is the parent of the
src
directory.The
apply
task (glob)mapper provides paths relative to the directory specified in itsdest
attribute:The relative path used is derived from the fileset specified, hence they do not contain the leading
src
directory.Options that come to mind are:
basedir
of the project instead ofproject.src.dir
(might work)<apply dest="src" ...
(better)