FDT Ant Tasks

From FDT Documentation

(Difference between revisions)
Jump to: navigation, search
(JRE - A Common Pitfall)
(JRE - A Common Pitfall)
Line 5: Line 5:
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.
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.
-
If you're just using the built in Ant tasks ( not FDT's Ant tasks ), you wont need to work about making sure your Ant tasks (file)  are operating as the same JRE (Java Run Time Environment) as FDT; however, if you plan on using FDT's Ant tasks, or FDT's Ant tasks along with Ant's built in tasks, you will.
+
Learn more about setting up the JRE with the [[FDT and Ant Tutorial]]
-
+
-
You"BUILD FAILED Could not create task or type ..." your task probably runs in another JRE. This can be corrected. Therefore got to "Run- >External Tools->External Tools..." in the main menu. Choose your run configuration and go to the tab "JRE". Change the option "Runtime JRE" from "Separate JRE" to "Run in the same JRE as the workspace".
+
= FDT Tasks  =
= FDT Tasks  =

Revision as of 16:53, 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.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.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>



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>


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