Eclipse FDT. Automatically embed a build control STRING.
On many occasions, it would have an interesting way to know if we have updated our flash projects, if are cached, etc …
A simple way of doing it is as follows:
We generate a file that contains our version number with a Ant build as follows:
1 2 3 4 5 6 7 8 9 10 11 | <?xml version="1.0" encoding="UTF-8"?> <project name="xxxx BUILDER" default="buildVersion" basedir=".."> <!-- DEFAULT TARGET --> <target name="buildVersion" > <!-- include a valid filePath --> <buildnumber file="yourpath/buildVersion.txt"/> </target> </project> |
Perfect, as we build our file with a nice number that is updated every time you execute it.
Now test it, the resulting file likes that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #Build Number for ANT. Do not edit! #Sat Nov 29 00:00:34 CET 2008 build.number=4 [cc lang="actionscript3"] package { import flash.utils.ByteArray; /** * @author xperiments */ [Embed(source="pathToYour/buildVersion.txt",mimeType="application/octet-stream")] public class EmbeddedVersion extends ByteArray { private var _revision : String; public function EmbeddedVersion() { var txtFile:String = this.toString( ); var lines:Array = txtFile.split("\n"); //asignamos el valor de revision _revision = String( lines[ 2 ].split('=')[ 1 ] ); } public function getRevision( ):String { return _revision; } } } |
Now for accessing to the actual revision value.
var embedInstance:EmbeddedVersion = new EmbeddedVersion( );
var revision:String = embedInstance.getRevision( );
trace( "Revision:" + revision );
We also have to modify the compilation settings in Ant tab Options (next to the tab Compiler Arguments) to include the previous buildVersion.xml file in the “ant prebuilt file.” parameter.
Nice coding…


