<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kris Range &#187; ant</title>
	<atom:link href="http://blog.krisrange.com/tag/ant/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.krisrange.com</link>
	<description>Web development</description>
	<lastBuildDate>Fri, 16 Sep 2011 15:23:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>ANT with JavaScript</title>
		<link>http://blog.krisrange.com/2010/05/ant-with-javascript/</link>
		<comments>http://blog.krisrange.com/2010/05/ant-with-javascript/#comments</comments>
		<pubDate>Thu, 20 May 2010 16:55:49 +0000</pubDate>
		<dc:creator>krange</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.krisrange.com/?p=26</guid>
		<description><![CDATA[Recently at work we had the need to build an application that could both be run over the network and on the local filesystem. Well, this doesn&#8217;t work with the Flash security setup as SWF files can only be run on one or the other. Like many other developers, we use ANT to build our [...]]]></description>
			<content:encoded><![CDATA[<p>Recently at work we had the need to build an application that could both be run over the network and on the local filesystem. Well, this doesn&#8217;t work with the Flash security setup as SWF files can only be run on one or the other. Like many other developers, we use ANT to build our projects and would like setting this property to be built into our build files. The SDK compiler has a nice property called &#8220;use-network&#8221; which can easily be set to true or false depending on your need which solves this situation nicely. The problem we ran into was with ANT and dealing with IF/ELSE target statements.</p>
<p>What we wanted to do was to use the same build SWF targets but for both situations without having to modify our process. Our solution was a nifty trick that used JavaScript inside ANT. I had never seen this technique before but some searching for a solution led us in this direction.</p>
<p>As you can see below, we have two initial targets, one which builds for local file system and one which builds for network use. We can then run either target first, which sets a property in our ANT file and then run our normal SWF build targets as normal, with this property set to the &#8220;use-network&#8221; property. Really looking forward to exploring some more complexities with JavaScript integration (as well as other languages from what I&#8217;ve read).</p>
<pre>
&lt;target name=&quot;compile_local&quot;&gt;
	&lt;script language=&quot;javascript&quot;&gt;
	&lt;![CDATA[
		presenter.setProperty( &quot;use-network&quot;, &quot;false&quot; );
	]]&gt;
	&lt;/script&gt;
&lt;/target&gt;
&lt;target name=&quot;compile_network&quot;&gt;
	&lt;script language=&quot;javascript&quot;&gt;
	&lt;![CDATA[
		presenter.setProperty( &quot;use-network&quot;, &quot;true&quot; );
	]]&gt;
	&lt;/script&gt;
&lt;/target&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.krisrange.com/2010/05/ant-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inserting build version numbers into Flash and Flex Applications</title>
		<link>http://blog.krisrange.com/2010/04/inserting-build-version-numbers-into-flash-and-flex-applications/</link>
		<comments>http://blog.krisrange.com/2010/04/inserting-build-version-numbers-into-flash-and-flex-applications/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 09:16:12 +0000</pubDate>
		<dc:creator>krange</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.krisrange.com/?p=12</guid>
		<description><![CDATA[For an ActionScript project I am currently working on (and for future projects), we wanted to be able to include the ANT build number into our applications when we do development and production quality releases to clients. The added value in this is that it is extremely helpful if you are constently pushing releases. It [...]]]></description>
			<content:encoded><![CDATA[<p>For an ActionScript project I am currently working on (and for future projects), we wanted to be able to include the ANT build number into our applications when we do development and production quality releases to clients. The added value in this is that it is extremely helpful if you are constently pushing releases. It saves time so that we can easily tell what version our clients are running on their development and production servers. This helps avoid unneeded debugging time making sure that the versions are correct. We also wanted this to happen automatically, or as much as possible, without the need for us to modify text files or add compiler variables.</p>
<p>Ok, lets get started! First, all of these instructions assumes you have a good knowledge in how ANT works. It also assumes you will be building an ActionScript or Flex project. In this case, we are going to be creating a custom ContextMenu but you can really do this for anything. This will allow anyone us to see the version numbers when they right click on our application.</p>
<p>Ok, so how is this done? Open up your build.properties file for the project and add the following lines:</p>
<pre>
project.major	  = 1
project.minor     = 0
project.revision  = 0
project.version   = ${project.major}.${project.minor}.${project.revision}
</pre>
<p>The projet will act as our properties for figuring out the project major, minor and revision. These could probably be automated in some way but for now I am ok with manually setting these values since I will know when these versions change. We will also need to include a build number into our build so just add the following before anything else into your build file. Also note that if this file does not exist, ANT will create it for you so no need to concern yourself with what the contents are. Let ANT do the dirty work!</p>
<pre>
&lt;buildnumber file=&quot;${basedir}/build/build.number&quot; /&gt;
</pre>
<p>Next, we are going to want to copy our classes to a temporary directory so that we can modify them without harming the source. As you can see I have some temp.outdir and classes.dir properties</p>
<pre>

&lt;target name=&quot;copyClasses&quot; description=&quot;Creates a temporary directory where the code will be duplicated so we can modify and build without harming the original files&quot;&gt;
	&lt;mkdir dir=&quot;${temp.outdir}&quot; /&gt;
	&lt;copy todir=&quot;${temp.outdir}&quot;&gt;
		&lt;fileset dir=&quot;${classes.dir}&quot;/&gt;
	&lt;/copy&gt;
&lt;/target&gt;
</pre>
<p>Now that our classes are copied, we need to do a search on them for particular strings that we will end up replacing with the project version. In my case, I have a ContextMenu class which has a string value defined as &#8220;[PROJECT_VERSION_NUMBER]&#8221; so I do a regular expression replace in ANT to find that value and replace it.</p>
<pre>

&lt;target name=&quot;projectversion&quot; description=&quot;&quot;&gt;
	&lt;replaceregexp match=&quot;[PROJECT_VERSION_NUMBER]&quot; replace=&quot;${project.fullname} : ${project.version}.${build.number}&quot; flags=&quot;gs&quot;&gt;
		&lt;fileset dir=&quot;${temp.outdir}&quot; includes=&quot;**/*.as&quot;/&gt;
	&lt;/replaceregexp&gt;
&lt;/target&gt;
</pre>
<p>And that is it. Now we have our build number plus project version automatically showing up in our application.</p>
<div style="text-align: center;"><img src="http://media.tumblr.com/tumblr_l0792hZFA61qa1ofo.png" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.krisrange.com/2010/04/inserting-build-version-numbers-into-flash-and-flex-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

