<?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>dispatchEvent()™ &#187; flexbilder</title>
	<atom:link href="http://dispatchevent.org/tag/flexbilder/feed/" rel="self" type="application/rss+xml" />
	<link>http://dispatchevent.org</link>
	<description>Collective thoughts on the Flash Platform, iOS, Unity, and any other technology we use.</description>
	<lastBuildDate>Tue, 07 Feb 2012 19:22:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using ant for Flex &#8211; a no B.S. guide &#8211; Part 4 of 4</title>
		<link>http://dispatchevent.org/mims/ant-for-flex-part-4/</link>
		<comments>http://dispatchevent.org/mims/ant-for-flex-part-4/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 03:31:43 +0000</pubDate>
		<dc:creator>Mims H Wright</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Tips, Tricks, and Hacks]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[flashbuilder]]></category>
		<category><![CDATA[flexbilder]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://dispatchevent.org/?p=771</guid>
		<description><![CDATA[Part 1 Part 2 Part 3 Part 4 Now that you&#8217;ve been through 3 exhaustive tutorials on ant for flex, it&#8217;s time to use your knowledge you&#8217;ve gained to turn your back on the built-in Flex compiler and switch to &#8230; <a href="http://dispatchevent.org/mims/ant-for-flex-part-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<ul>
<li><a href="http://dispatchevent.org/mims/ant-for-flex-part-1/">Part 1</a></li>
<li><a href="http://dispatchevent.org/mims/ant-for-flex-part-2/">Part 2</a></li>
<li><a href="http://dispatchevent.org/mims/ant-for-flex-part-3/">Part 3</a></li>
<li>Part 4</li>
</ul>
<p>Now that you&#8217;ve been through 3 exhaustive tutorials on ant for flex, it&#8217;s time to use your knowledge you&#8217;ve gained to turn your back on the built-in Flex compiler and switch to ant for your builds. This part applies to FlexBuilder (and FlashBuilder) users only although it may apply if you&#8217;re using some other eclipse-based plugin. If you&#8217;re using another program like TextMate or Flash CSx, you can skip this article.<br />
<span id="more-771"></span></p>
<h3>Replacing the default builder with your ant tasks</h3>
<p>The rest of this article will show you how to use your ant build script to perform the building actions found in FlashBuilder.</p>
<p>In FlashBuilder, the following building actions can be executed</p>
<ul>
<li><strong>Build Project &#8211; </strong>Occurs when the user manually builds the project.</li>
<li><strong>Build Automatically &#8211; </strong>When the option is checked in the Project menu, the code is automatically build when you save a file. Usually incrementally.</li>
<li><strong>Clean</strong> &#8211; &#8216;cleans&#8217; the project folder by doing a complete, non-incremental build and removing temporary files.</li>
</ul>
<p>These actions are all called by various actions and handled by one or more <em>builders</em>. In terms of the eclipse SDK, a builder is an XML file that describes how the various build actions will be executed. In FlashBuilder, all of these are set up to use the Flex &#8220;builder&#8221; by default. You can add new customized builders to supplement these build actions. You can also deactivate the default builder an just use your ant builds instead <strong>but you will lose the ability to see inline errors in your code</strong>.</p>
<p>In order for this to work however, you need to start out with some solid, well-tested ant tasks.</p>
<h4>Step 1 &#8211; Create the appropriate ant targets</h4>
<p>Create a target in your build.xml for each of the actions listed above. Call each target &#8220;build&#8221;, &#8220;autoBuild&#8221;, and &#8220;clean&#8221;. You can probably start with the &#8220;build&#8221; target and reuse it for the other two. To write an incremental build target (used for the build-automatically action) there is an example in<a href="http://dispatchevent.org/mims/ant-for-flex-part-2/"> Part 2</a> of this article.</p>
<p>Before moving on, please test your build script thoroughly to be sure there are no errors and that your files are compiling correctly.</p>
<p>Note, I&#8217;m not going to go into the details here about exactly how to write your ant script. If you&#8217;re considering switching to ant as your primary builder then A) your project has special needs that need to be addressed by a custom build script and I don&#8217;t know what those needs are and B) you need to know what you&#8217;re doing with ant before completely abandoning FlashBuilder&#8217;s defaults. I will say, save the fancy stuff for your release build targets and do incremental builds by default since you&#8217;ll be running these scripts quite a lot.</p>
<h4>Step 2 &#8211; Create a builder for your ant build script</h4>
<ol>
<li>Open the properties for the project you want to edit. <strong>Project -&gt; Properties</strong></li>
<li><strong>Select the Builders item</strong> in the left menu. You will see that the default builder &#8220;Flex&#8221; is already set up.</li>
<li><strong>Click the New&#8230; button</strong>. A dialog will come up with templates for the new builder.</li>
<li><strong>Choose the &#8220;Program&#8221; type</strong>. (On my configuration, I see an option for &#8220;Ant Builder&#8221; also which is what I should probably be using, however, I haven&#8217;t gotten it to work yet and it doesn&#8217;t seem to generate any specific errors when it fails so I gave up and went with Program. If you know how to fix this, let me know!)</li>
<li><strong>Name the builder &#8220;flexAntBuilder&#8221;</strong></li>
<li><strong>Set the location field to the ant binary you&#8217;re using.</strong> If you&#8217;re not sure where the binary is located, you can use the command <code>which ant</code> in the command line. Mine is at <code>/usr/bin/ant</code></li>
<li><strong>Set the Working directory to your project&#8217;s home directory</strong>. If you&#8217;re not sure, browse to it.</li>
<li><strong>In the arguments field, enter the name of the target you want to run. </strong>In this case <code>build</code>.</li>
<li><strong>Optional: Click on the Refresh tab.</strong> Here you can chose whether to refresh the files in your workspace when the build completes.</li>
<li><strong>Click on the Build Options tab. </strong>Here, under the &#8220;Run the Builder:&#8221; heading near the bottom, is where you&#8217;re going to set the properties that determine when this particular task is run. For the &#8216;build&#8217; target, <strong>uncheck everything except &#8220;During Manual Builds&#8221;.</strong>
<ul>
<li>For your &#8220;autoBuild&#8221; target, you&#8217;re going to uncheck everything except &#8220;During auto builds&#8221;</li>
<li>For your &#8220;clean&#8221; target, you&#8217;re going to uncheck everything except &#8220;After a clean&#8221;</li>
</ul>
</li>
<li><strong>Repeat steps 1-10 for the other two targets.</strong></li>
<li>When all targets are added,<strong> </strong><strong>optionally</strong><strong> uncheck the &#8220;flex&#8221; builder from the builders menu in your project properties to use the ant tasks exclusively.</strong> Now your ant scripts will be used instead of the flex builder.</li>
</ol>
<p>That&#8217;s it! Be sure to test things and make sure you&#8217;re not getting any errors.</p>
<h4>What to expect from here</h4>
<p>So you&#8217;ve unchained yourself from the system and are using your ant scripts to build your project. Congratulations, you&#8217;re a huge nerd! From this point on, changing the compile settings in the Project Properties dialog (like the build path) may be ineffective. You&#8217;ll need to make changes to your build path in the ant file.</p>
<p>The results from your builds will appear in the Console view. Here you can see the progress of builds and check for errors in the code. As I mentioned before, if you deactivate the flex builder you won&#8217;t get inline errors in your code any longer.</p>
<p>Finally, adding the new builders will create a new invisible folder in your project&#8217;s root folder called .externalToolBuilders where your builder definitions will be kept. You don&#8217;t need to do anything with this folder, but be aware that it&#8217;s there.</p>
<p>That concludes this 4 part epic post about ant tasks for flex! I hope you found it useful. If you have anything to add, please post comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://dispatchevent.org/mims/ant-for-flex-part-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

