FDT Ant Tasks

From FDT Documentation

(Difference between revisions)
Jump to: navigation, search
(fdt.extSWFViewer.startSWF)
(fdt.startDebugger)
Line 217: Line 217:
'''Example''': Start the debugger.
'''Example''': Start the debugger.
-
 
----
----

Revision as of 18:41, 20 September 2010

Along with support for ANT's built in tasks, FDT provides some Ant tasks of its own. To assure that these tasks work, the task has to run in the same JRE (Java Runtime Environment) as Eclipse.

Contents

JRE - A Common Pitfall

Before getting into Ant, an important concept to understand is how Ant tools, by default, run in their own JRE. If you get the error: BUILD FAILED Could not create task or type ... - it's most likely because your Ant file is not executing in the same JRE as FDT.

Learn more about setting up the JRE with the FDT and Ant Tutorial

FDT Tasks

fdt.browse

Opens a document in the Browser.

<fdt.viewDocument location="url" />

Arguments:

  1. location : the location of the file to open.

Example: Open index.php located on a local server in the default browser.

<project default="default">
  <target name="default">
    <fdt.viewDocument location="http://localhost/index.php" /> 
  </target>
</project>



fdt.extSWFViewer.focusWindow

Focuses a running process. The window pop up to the foreground.

<fdt.extSWFViewer.focusWindow process="executable" />

Arguments:

  1. process : the name of the process to focus.

Example: Set focus to Eclipse.

<project default="default">
  <target name="default">
    <fdt.extSWFViewer.focusWindow process="javaw.exe" />
  </target>
</project>



fdt.extSWFViewer.startSWF

An existing SWF file is started in the external SWF Viewer.

<fdt.extSWFViewer.focusWindow process="executable" />


Arguments:

  1. file : the name of the file to run.
  2. width : the width of the window.
  3. height : the height of the window.
  4. flashvars : the variables passing to Flash (optional).
  5. focusprocess : the name of the process to focus (optional).

Example: Start SWF in external swf viewer with given size and flashvars and set focus to Flash IDE.

<project default="default">
  <target name="default">
    <fdt.extSWFViewer.startSWF file="${basedir}/start.swf" width="640" height="480" 
         flashvars="a=1&amp;b=2" focusprocess="flash.exe"/>
  </target> 
</project>



fdt.flashCompile

This task compiles a single FLA or a set of FLA's with the Flash IDE. The Flash IDE must be set in the Flash Preferences (see "Preparing the workbench (AS2)"). The Flash Output is captured and shown in the console. If any error occurs the build will be aborted. You can define a timeout for how long the build waits for the output. If the timeout is not specified the task will take a 60 second timeout.

<fdt.flashCompile file="fla" timeout="t in ms " />


Arguments:

  1. file : the FLA to compile
  2. timeout : the timeout(ms) for how long the tasks wait until it fails
  3. failonerror : whether the ant should fail if flash outputs something. Default is "true"


Example: Compile for a single FLA with a timout of 5 seconds.

<project default="default"> <target name="default">
  <fdt.flashCompile file="${basedir}/start.fla" timeout="5000"> </target>
</project>


Example: Compile for a set of FLA's and two additional FLA's.

<project default="default">
  <target name="default">
    <fdt.flashCompile> 
      <fileset dir="${basedir}">
         <include name="*.fla"/>
      </fileset>
    </fdt.flashCompile>
    <fdt.flashCompile file="${basedir}/data/start.fla" failonerror="false"/> 
    <fdt.flashCompile file="${basedir}/data/main.fla"/>
   </target> 
</project>



fdt.launch.application

To use the FDT launch capabilities for AS3 from ANT use this task. You can compile your source to an SWF and optionaly launch this with one of the SWF viewers. If FCSH is installed it is used for incremental compiling.

<fdt.launch.application projectname="HelloWorld" mainclass="src/test/Main.as" debug="true"  
    target="${basedir}/Main.swf" startswf="true" swflauncher="Adobe Flash Player"/>


Arguments:

  1. projectname : the name of the project that contains the source.
  2. mainclass : the path to the mainclass to create the SWF for, relative to the used project
  3. debug : compile the SWF for debugging or not
  4. target : the path to the SWF to create, relative to the used project
  5. compilerarguments : any arguments that should be used for compiling. If no arguments are provided FDT default arguments are used.
  6. startswf : should the created SWF launched immediatly?
  7. swflauncher : The name of the viewer that should be used for launching the SWF ... one of "External SWF Viewer", "Adobe Flash Player", "Browser" or "Internal SWF Viewer".


Example: Simply compile to an SWF.

<project default="default">
  <target name="default">
    <fdt.launch.application projectname="HelloWorld" mainclass="src/test/Main.as"
         debug="true" target="${basedir}/Main.swf" startswf="false"/>
  </target>
</project>



fdt.launch.library

To create SWC files for AS3 you can use this task. All options from the "AS3 FDT Library" launcher are available.

<fdt.launch.library projectname="HelloWorld" debug="true" target="${basedir}/Main.swc" />

Arguments:

  1. projectname : the name of the project that contains the source.
  2. debug : compile the SWC for debugging or not
  3. target : the path to the SWC to create, relative to the used project
  4. compilerarguments : any arguments that should be used for compiling. If no arguments are provided FDT default arguments are used.

Example: Compile code to a SWC.

 
<project default="default">
  <target name="default">
    <fdt.launch.library projectname="HelloWorld" debug="true"
         target="${basedir}/Main.swc" />
  </target>
</project>



fdt.launch.resetFlexCompiler

FDT uses an incremental compilation process that reduces compile time significantly. It does this by keeping certain variables in memory; however, there may be a time when you need to reset FDT's compilation process because your class path or some other configuration has changed. When this task is run all incremental information is discarded and next time FDT builds it will be a full build.

This task has no arguments and simply calling it will reset FDT's compiler.

<fdt.launch.resetFlexCompiler/>



fdt.startDebugger

If you have FDT MAX installed, you can use the debugger feature. Make sure your .SWF has been compiled and is currently running.

 <fdt.startDebugger projectname="HelloWorld" />

Arguments:

  1. projectname: Name of the project whose source code is associated with the running .SWF.
  2. targetswf: The .SWF to target.
  3. taskname:

Example: Start the debugger.


fdt.startProfiler

Another feature with FDT MAX is the Profiler. Use this to connect to a running .SWF

<fdt.startProfiler />

Arguments:

  1. collectstackdata:
  2. description:
  3. excludedpackages:
  4. filterinternalactions:
  5. filterinternalpackages:
  6. includedpackages:
  7. memoryprofilingenabled:
  8. performanceprofilingenabled:
  9. projectname:
  10. targetswf:

Example: Start the profiler.



fdt.viewDocument

Opens a document in the internal SWF Viewer. You can open all types accepted by a browser (html, php, swf, ...).

<fdt.viewDocument location="swf" />

Arguments:

  1. location : the location of the file to open.

Example: Compile for a FLA and show the created SWF in the SWF Viewer.

<project default="default">
  <target name="default">
    <fdt.flashCompile file="${basedir}/main.fla" />
    <fdt.viewDocument location="${basedir}/main.swf" /> 
  </target>
</project>

Other Important Ant Tasks

Ant provides a large number of pre-defined tasks. A good introduction into Ant together with the explanation of the pre-defined tasks can be found in Ant's User's Manual. Some of the for us important ones are briefly described in the following.

exec

Runs an executable file. Example: Call up of the command line in windows and execution of a ".bat" file.

<target name="run bat"> 
  <exec executable="cmd">
    <arg value="/c"/> 
    <arg value="ant.bat"/> 
    <arg value="-p"/>
  </exec> 
</target>



copy

Copies one or several files/directories.

Example: Make a copy of a single file.

<copy file="myfile.txt" tofile="mycopy.txt"/>


Example: Make a copy of one directory into another one.

<copy todir="../new/dir"> 
  <fileset dir="src_dir"/>
</copy>



zip

Creates a ".zip" file.

Example: Zip a directory and an additional file.

<zip destfile="${dist}/manual.zip"> 
  <fileset dir="htdocs/manual"/> 
  <fileset dir="." includes="ChangeLog.txt"/>
</zip>
Get FDT5