FDT Ant Tasks

From FDT Documentation

(Difference between revisions)
Jump to: navigation, search
(fdt.extSWFViewer.startSWF)
(fdt.extSWFViewer.startSWF)
Line 57: Line 57:
==fdt.extSWFViewer.startSWF==
==fdt.extSWFViewer.startSWF==
-
Focuses a running process. The window pop up to the foreground.
+
An existing SWF file is started in the external SWF Viewer.
 +
<syntaxhighlight lang="xml">
<fdt.extSWFViewer.focusWindow process="executable" />
<fdt.extSWFViewer.focusWindow process="executable" />
-
Arguments:
+
</syntaxhighlight>
-
process : the name of the process to focus.
+
 
-
Example: Set focus to Eclipse.
+
'''Arguments''':
 +
 
 +
#'''file''' : the name of the file to run.
 +
#'''width''' : the width of the window.
 +
#'''height''' : the height of the window.
 +
#'''flashvars''' : the variables passing to Flash (optional).
 +
#'''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">
<project default="default">
   <target name="default">
   <target name="default">
-
     <fdt.extSWFViewer.focusWindow process="javaw.exe" />
+
     <fdt.extSWFViewer.startSWF file="${basedir}/start.swf" width="640" height="480" flashvars="a=1&amp;b=2" focusprocess="flash.exe"/>
-
   </target>
+
   </target>  
</project>
</project>

Revision as of 17:43, 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&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.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