Copy link to clipboard
Copied
Hello,
Anyone know of a plugin or something that will increment the build number of an app each time it is compiled? I'm looking for something similar to a plugin that Flashdevelop uses, were the app version and build number is kept within an AS3 class file and is updated automatically each time the project is built.
thx
Copy link to clipboard
Copied
This may not be as direct a solution as you want.
You can add the Ant Eclipse extension, and use an Ant task to do modify source code as part of the build process. The Ant task could read a source file, increment an embedded version string and then build. (Maybe a real Ant expert could help here.)
Oz
Copy link to clipboard
Copied
I am no Ant expert, but I use an Ant task to update the version number in the Air descriptor file of one of our apps. With a little tweaking you should be able get it to do what you need. Perhaps you could store the build number in an xml file and read it into your AS3 file, which I think would be better than having an external script (i.e. Ant) modify your AS3 code.
Here's the part of my Ant build that increments the build number in the main.xml (descriptor) xml file:
<!-- xml task for writing to xml files -->
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
<target name="increment">
<propertyfile file="build.number">
<entry key="build.number" type="int" operation="+" default="1"/>
</propertyfile>
<property file="build.number"/>
<echo message="Build number is ${build.number}"/>
<xmltask preservetype="true" report="true" source="${APP_XML}" dest="${APP_XML}">
<regexp path="//*/text()" pattern="1.0.([0-9]*)" replace="1.0.${build.number}"/>
</xmltask>
</target>
That task increments the build portion of our version number (i.e. <major>.<minor>.<build>), which is in an XML node: <versionNumber>1.0.12345</versionNumber> in the Air descriptor file.
To manipulate XMLyou need the xmlTask jar (http://www.oopsconsultancy.com/software/xmltask/#download). I had troubles with the regexp traversing a specific XPath so I used the very vague regex you see, which works in our case. I think they may have fixed the regexp issue since then though.
Also, for that task to work you'll need to create a file named build.number in your project root and make sure you have the ${APP_XML} var set to the full path of your xml file that will house the build number node. Note: you could just read the build.number file into your class file, but I've always found reading XML into as3 is easiser to work with.
--Abram
Copy link to clipboard
Copied
Hello,
Thanks for the suggestions... I've used Ant a little bit, so I think I can figure this out.
rgds