Flex: Custom HTML Wrappers In Ant

Building Flex using ant build files is generally straightforward. Unfortunately, this is not so with using custom HTML wrappers. You cannot use the html-wrapper task since this only uses the standard templates in Flex’s html-template folder. If you want to use your own index.template.html in your own html-template folder, you will need to use a workaround:

<macrodef name=”generateHtmlWrapper” description=”Generates HTML Wrapper using custom template”>
<attribute name=”file”/>
<attribute name=”title”/>
<attribute name=”application”/>
<attribute name=”swf”/>
<attribute name=”width”/>
<attribute name=”height”/>
<attribute name=”bgcolor”/>
<attribute name=”version-major”/>
<attribute name=”version-minor”/>
<attribute name=”version-revision”/><attribute name=”template”/> <attribute name=”output”/>

<sequential>
<copy todir=”@{output}/history”>
<fileset dir=”html-template/history”/>
</copy>             
<copy file=”html-template/AC_OETags.js” todir=”@{output}”/>
<copy file=”html-template/playerProductInstall.swf” todir=”@{output}” />
<copy file=”html-template/index.template.html” tofile=”@{output}/@{file}” />

<replace file=”@{output}/@{file}” token=”$${title}” value=”@{title}”/>
<replace file=”@{output}/@{file}” token=”$${swf}” value=”@{swf}”/>
<replace file=”@{output}/@{file}” token=”$${width}” value=”@{width}”/>
<replace file=”@{output}/@{file}” token=”$${height}” value=”@{height}”/>
<replace file=”@{output}/@{file}” token=”$${bgcolor}” value=”@{bgcolor}”/>
<replace file=”@{output}/@{file}” token=”$${application}” value=”@{application}”/>
<replace file=”@{output}/@{file}” token=”$${version_major}” value=”@{version-major}”/>
<replace file=”@{output}/@{file}” token=”$${version_minor}” value=”@{version-minor}”/>
<replace file=”@{output}/@{file}” token=”$${version_revision}” value=”@{version-revision}”/>
</sequential>
</macrodef>

Thanks to Renaun Erickson for the solution!

2 Replies to “Flex: Custom HTML Wrappers In Ant”

  1. Just wanted to post and say thanks for your article. It helps me alot. Only in your blog i’ve realized that flex sdk can’t build html wrapper from a template.

Comments are closed.