Running Ant From FlashDevelop 3 · Mar 23, 06:55 AM


Kieth Peters figured this out over a year ago. However, follow his directions for the latest version of FlashDevelop (version 3, RC2) and you might run into some trouble. I’ll make this really easy for y’all.

Directions: Adding Ant to FlashDevelop

  • Obviously, you need to have Ant installed.

  • Make sure that Ant’s bin folder is in your Windows System Path Environment Variable. You can do this by right-clicking My Computer, choose properties, navigate to the Advanced tab and click the Environment Variables button. Then add the path to the bottom box.

  • Add the following two lines to C:\Program Files\FlashDevelop\Settings\ToolBar.xml directly before </toolbar> (at the end of the file).

  1. <separator />
  2. <button label="ANT Build" click="RunProcessCaptured" image="486" tag="c:\windows\system32\cmd.exe;/c $(Quote)cd $(ProjectDir)&amp;&amp;ant$(Quote)" />
  3. Download this code: /files/fdant.txt

  • Replace C:\Program Files\FlashDevelop\Settings\Images.png with this file

  • Restart FlashDevelop

  • Place your Ant build.xml in your project folder.

Now whenever you click on your newly created Ant button, Ant will build your project based on the build.xml.

Ant-ing a Different Build.xml

I’ve added another button to my work-flow that builds a file named build.test.xml. This file imports build.xml and then executes my main SWF file (AppMain.swf) after the build is complete. Here is what my build.test.xml looks like (note: compile is the default target in buld.xml):

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <project name="Tester" default="Test" basedir=".">
  3. <description>Test SWF</description>
  4.  
  5. <import file="build.xml" />
  6.  
  7. <property name="testswf" location="${basedir}\bin\AppMain.swf"/>
  8. <property name="flashviewer" location="C:\Program Files\Adobe\Adobe Flash CS3\Players\Debug\FlashPlayer.exe"/>
  9.  
  10. <target name="Test" depends="compile">
  11. <exec executable="${flashviewer}" failonerror="true">
  12. <arg value="${testswf}"/>
  13. </exec>
  14. </target>
  15.  
  16. </project>
  17. Download this code: /files/fdant2.txt

  • Create your build.test.xml similar to the one above, and put it in the same folder as build.xml

  • Add the following line to C:\Program Files\FlashDevelop\Settings\ToolBar.xml directly before </toolbar> (at the end of the file).

  1. <button label="ANT Build and Test" click="RunProcessCaptured" image="487" tag="c:\windows\system32\cmd.exe;/c $(Quote)cd $(ProjectDir)&amp;&amp;ant -buildfile build.test.xml$(Quote)" />
  2. Download this code: /files/fdant3.txt

The Alternate Method

  • Create a new FlashDevelop Project named Build.

  • From the Project menu, click Properties….

  • From the Output tab check the No output, only run pre/post build commands box

  • From the Build tab enter c:\apache-ant\bin\ant.bat in the Pre-Build Command Line box. Of course you should use the correct ant bin path.

  • Click Ok

  • From this project, whenever you click Build Project or Test Movie your Ant build will run.

— Pickle

---

Comment

  1. thanks a lot for your post.
    you really made my work easier ;)

    sébastien · May 7, 11:17 AM · #

  2. no problemo!

    Pickle · May 7, 08:51 PM · #

  3. Very helpful and great icons.
    Thanks.

    Trevor · Sep 19, 09:12 AM · #

  4. Great stuff,

    But I wonder the build.xml file you speak of : Do you have an example
    of one ?

    I would like to be able to compile my projects in FD3 with Ant, or say
    Im curious how to. I set things up as per above.

    But the build.xml file alludes me and have yet not readup fully on the ant documentation…

    Thomas

    Thomas · Oct 24, 08:42 AM · #

  5. @Tomas Here’s an example build.xml…

    
    <?xml version="1.0" encoding="utf-8" ?> 
    <project name="MyProject" default="compile" basedir=".">
    	<description>Compile MyProject</description>
    
    	<property name="fdproj1" location="${basedir}\App.as3proj"/>
    	<property name="fdproj2" location="${basedir}\Home.as3proj"/>
    
    	<property name="fdbuild" location="C:\Program Files\FlashDevelop\Tools\fdbuild\fdbuild.exe"/>
    	<property name="compiler" location="C:\flex_sdk_3"/>
    	<property name="library"  location="C:\Program Files\FlashDevelop\Library"/>
    
    	<target name="Project1">
    		<echo message="Compiling ${fdproj1}."/>
    		<exec executable="${fdbuild}" failonerror="true">
    			<arg value="${fdproj1}"/>
    			<arg value="-compiler"/>
    			<arg value="${compiler}"/>
    			<arg value="-library"/>
    			<arg value="${library}"/>
    		</exec>
    	</target>
    
    	<target name="Project2" depends="Project1">
    		<echo message="Compiling ${fdproj2}."/>
    		<exec executable="${fdbuild}" failonerror="true">
    			<arg value="${fdproj2}"/>
    			<arg value="-compiler"/>
    			<arg value="${compiler}"/>
    			<arg value="-library"/>
    			<arg value="${library}"/>
    		</exec>
    	</target>
    
    	<target name="compile" depends="Project2,Project3">
    		<echo message="Compiling ${compile}."/>
    		<exec executable="${fdbuild}" failonerror="true">
    			<arg value="${compile}"/>
    			<arg value="-compiler"/>
    			<arg value="${compiler}"/>
    			<arg value="-library"/>
    			<arg value="${library}"/>
    		</exec>
    	</target>
    </project>
    

    Pickle · Oct 25, 07:49 AM · #

Textile Help