Assembling Adobe Air installers is pretty easy. In this article Iâ€™ll show you how to put together an ant build.xml file which will build for you.
For the incurably impatient here is the whole thing:
Letâ€™s break it down a bit
Here we set up some properties to be used in the rest of the file. Iâ€™m sure I donâ€™t have to quote the Pragmatic Programmer about repeating yourself.
Air applications have to be signed. As part of a release process youâ€™ll want to generate a proper key and keep in somewhere safe like on a cd in the catâ€™s litter box. However we donâ€™t want developer builds getting out into the wild so weâ€™ll just generate a key here and use it.
Youâ€™ll notice on line 12 we sleep for a couple of seconds. Why is that? It turns out that the key generator returns before it is actually done generating so weâ€™ll give it a few more seconds otherwise youâ€™ll get an error like
failed while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="invalid package signature" errorID=5022]
starting cleanup of temporary files
application installer exiting
in the Air installation log. (See http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403123 to read how to enable logging of Air installations)
Finally we come to actually building the application
Here Iâ€™m replacing the version number in the application.xml with the SVN_REVISION. Our builds run from inside the wonderful Hudson build management system which is kind enough to pass through a token containing the revision number from SVN. We finally execute adt the Air packaging tool giving it a list of the files we would like to have inside the package. We list them by hand as a double check against accidentally including extra files, like bankingInformation.xls.
Thatâ€™s it! The only real trick is pausing for the key generation to complete.