0

I'm trying to fix a bug in the HTML5 Boilerplate ant task. Theres a "manifest" target to automatically create an html5 cache manifest file.

line 717 in the build script is the area which has a bug:

            <!-- add image files -->
            <echo message="Updating the site.manifest with the images"/>
            <for param="file">
                <path>
                    <fileset dir="./${dir.source}/${dir.images}/" includes="**/*"/>
                </path>
                <sequential>
                    <basename property="filename.@{file}" file="@{file}" />
                    <replaceregexp match="# image files" replace="# image files${line.separator}${dir.images}/${filename.@{file}}" file="${dir.intermediate}/${file.manifest}" />
                </sequential>
            </for>

The issue is, given a directory structure like:

img/image1.jpg
img/subdir/image2.jpg

the output ignores the subdirectory:

img/image1.jpg
img/image2.jpg

What is the best way to fix this issue?

LessQuesar
  • 3,123
  • 1
  • 21
  • 29

1 Answers1

0

I figured it out:

            <!-- add image files -->
            <echo message="Updating the site.manifest with the images"/>
            <for param="file">
                <path>
                    <fileset dir="./${dir.source}/${dir.images}/" includes="**/*"/>
                </path>

                <sequential>
                    <path id="fullPath.@{file}">
                        <pathelement location="@{file}" />
                    </path> 
                    <pathconvert property="relPath.@{file}" refid="fullPath.@{file}">
                        <globmapper from="${basedir}/*" to="*" />
                    </pathconvert>
                    <replaceregexp match="# image files" replace="# image files${line.separator}${relPath.@{file}}" file="${dir.intermediate}/${file.manifest}" />
                </sequential>
            </for>

It gets the absolute path of the element, then removes the ${basedir} portion with globmapper, which leaves the relative path to the image.

LessQuesar
  • 3,123
  • 1
  • 21
  • 29