ANT Task for using html-template’s index.template.html
July 31st, 2007
I am constantly changing the default index.template.html in my Flex projects. This is quite nice, as you can even change the index.template.html to index.template.php and it will generate the file correctly. But in most cases I have ANT builds on the servers that do all the building. This is where I found the Flex ANT html-wrapper task falling short.
The Flex ANT html-wrapper task does not let you use custom/modified template files. But don't worry its actually quite easy to do this in ANT, as its just a bunch of token substitution. Here is one way to accomplish the task (I was having issues with filterchain and replacetokens):
-
<copy file="${app.base.dir}/html-template/index.template.html"
-
tofile="${app.webroot.dir}/MyApp.html" />
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${swf}" value="MyApp"/>
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${width}" value="600"/>
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${height}" value="600"/>
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${bgcolor}" value="#000000"/>
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${application}" value="MyApp"/>
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${version_major}" value="9"/>
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${version_minor}" value="0"/>
-
<replace file="${app.webroot.dir}/MyApp.html" token="$${version_revision}" value="28"/>
Entry Filed under: Adobe Flex, Rich Internet Applications



10 Comments Add your own
1. Dan G. Switzer, II | 2007-08-01 at 6.50 am
Have you been able to configure your ANT scripts to automatically run on save?
Mine seem to require that I manually trigger the ANT scripts.
Any tips?
2. Renaun Erickson | 2007-08-10 at 11.44 am
No any pre/post compile firing of other programs is not possible yet. We should ask for this feature with the Flex Builder.
3. David Coletta | 2007-08-22 at 9.58 am
There’s another way to do this, if I’m understanding your post. (This is via Mike Morearty.) The filename for the main index.template.html file is hard-coded to that filename. But the contents of that file are under your control — it gets that file from the appropriate subdirectory of /resources/html-templates.
4. Renaun Erickson | 2007-08-22 at 10.11 am
David,
Yes you are right, I modify the index.template.html all the time. You can actually add other Xxxx.template.html to the folder and Flex Builder will replace them too. But this post is for the build servers that do not use Flex Builder and need to output the templates, and I wanted to keep the same template for development and build scripts.
5. David Coletta | 2007-08-22 at 11.10 am
OK, that makes sense.
6. RIA pedia - Rich Internet&hellip | 2007-09-28 at 1.22 pm
Heading to MAX on Sunday…
I’m heading to Adobe MAX North America<?a> on Sunday. If you’re in Chicago for the event, drop by the Flex booth to say hi. I’ll be there every day, or you can also find me helping out with Renaun Erickson’s sessions on Flex and PHP. I’l…
7. Brian Thornton | 2007-10-05 at 1.54 pm
Any idea where you can find a complete list of the vars that by defauly are found in index.template.html?
8. Brian Thornton | 2007-10-05 at 1.57 pm
Also keep in mind when changing it http://www.morearty.com/blog/2006/12/11/changing-the-filenames-in-flex-builder-html-templates/
That changing extension mean changing the project properties..
9. Renaun Erickson | 2007-10-05 at 4.54 pm
don’t know of the complete list that are defaults of the Flex Project
10. Continuous Build: Flex Bu&hellip | 2008-01-03 at 2.07 pm
[...] In Flex land, things are a little different . Reading Adobe’s Ant Task page you’d expect things to be fairly simple. Unfortunately the Ant Tasks page isn’t very specific about how to pass in library references for , luckily you can guess the answer from this blog - compiler.library-path. include-classes is another headache that Straylink offers a solution. index.template.html is again poorly documented by Adobe, but Renaun Erickson’s posting together with Mike Morearty who nicely documents the marco’s. If you’ve got this far, you need to consider added your FlexUnit’s to Ant. [...]
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed