Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me


Forum's topics

Latest Files


Top Rated


Photo Gallery

Alessandro Crugnola on January 31, 2010 in actionscript

Update your app VERSION using ant

This is just a quick tip in case someone needs it. Maybe when you compile your flash application or your swc library you want to automatically update the "VERSION" number too without do it manually every time.
This is the way I do. In the "compile" task I've added a depends link to this ant task:

<target name="update-version">
	<propertyset id="tdate"></propertyset>
		<format property="tdate" pattern="yyyyMMdd"/>
	<buildnumber file="build.number"/>
	<echo>updating version to current datetime: ${tdate}</echo>
	<replaceregexp byline="true">
		<regexp pattern="public static const BUILD_DATE: String = \'([0-9]+)'"/>
		<substitution expression="public static const BUILD_DATE: String = '${tdate}'"/>
		<fileset dir="src/it/sephiroth/somestuff">
			<include name=""/>
	<replaceregexp byline="true">
		<regexp pattern="public static const BUILD_NUMBER: String = \'([0-9\.]+)'"/>
		<substitution expression="public static const BUILD_NUMBER: String = '${build.number}'"/>
		<fileset dir="src/it/sephiroth/somestuff">
			<include name=""/>

The 2 optional tasks I've used are: BuildNumber task and ReplaceRegExp Task. In this way every time I do an ant compile, it will update my build number and modification date.
What this task does is find this 2 lines in my file:

public static const BUILD_DATE: String = '20100131';


public static const BUILD_NUMBER: String = '5';

then replace the BUILD_DATE const with the current date and the BUILD_NUMBER with an incremental build number. After being executed the first time, ant will also create a new file in your directory called "build.number" with the latest build number int.


Bookmark and Share


Tags: ant 


Nice, I was just thinking about it this weekend and wanted to make something like this, saves me some time to do something else! :) I would also like the SVN revision number in, but I might use your 'template' to create a thing like that. (Or do you happen to have something for it already?)

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Type the characters you see in the picture above.



TrackBack URL for this entry: