A simple template that helps with building with a custom services.xml for flex, and deploying files with SCP.

First making sure Flex can handle Flex tasks by pointing to the according jar.

<?xml version="1.0" encoding="utf-8"?>
<project name="somesite" basedir=".">
 
	<taskdef resource="flexTasks.tasks"
        classpath="${basedir}/libs/flexTasks.jar"/>

The next part defines paths as properties. This is not just saving typing but also allows to have different profiles for different developer machines.

	<property name="FLEX_HOME" value="/Applications/Adobe Flex Builder 3/sdks/3.2.0"/>
        <property name="APP_ROOT" value="src/"/>
	<property name="SITE_ROOT" value="/svn/somesite.com/httpdocs/"/>

The main tasks compiles the project with a services config. Usually this config points to the live deploying url while the local flex configuration points to the local test server.

    <target name="main">
        <mxmlc file="${APP_ROOT}/admin.mxml" keep-generated-actionscript="true" services="/svn/somesite.com/flex/CharacterAdmin/services-config-deloy.xml">
            <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
            <source-path path-element="${FLEX_HOME}/frameworks"/>
        </mxmlc>
    </target>

The next part is a helper task that copies the created SWF to the local web root. This is usefull when the whole directory is getting deplyed.

	<target name="copySwfToLocalWebRoot">
		<copy file="${APP_ROOT}/admin.swf" todir="${SITE_ROOT-}sites/default/files/flash" overwrite="true"/>
	</target>

Finally the task to deploy the compiled flex movie onto the server using SCP. The plugin I use is Jsch. To install it, copy the file to your deployment folder and add it in your Eclipse Configuration (Ant Section, Runtime path).

	<target name="deploy">
		<scp file="${SITE_ROOT-}sites/default/files/flash/admin.swf" todir="USER:PASSWORD@SERVER:/var/www/vhosts/somesite.com/httpdocs/sites/default/files/flash"/>
	</target>
 
</project>

Complete:

<?xml version="1.0" encoding="utf-8"?>
<project name="somesite" basedir=".">
 
	<taskdef resource="flexTasks.tasks"
        classpath="${basedir}/libs/flexTasks.jar"/>
 
	<property name="FLEX_HOME" value="/Applications/Adobe Flex Builder 3/sdks/3.2.0"/>
        <property name="APP_ROOT" value="src/"/>
	<property name="SITE_ROOT" value="/svn/somesite.com/httpdocs/"/>
 
    <target name="main">
        <mxmlc file="${APP_ROOT}/admin.mxml" keep-generated-actionscript="true" services="/svn/somesite.com/flex/CharacterAdmin/services-config-deloy.xml">
            <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
            <source-path path-element="${FLEX_HOME}/frameworks"/>
        </mxmlc>
    </target>
 
	<target name="copySwfToLocalWebRoot">
		<copy file="${APP_ROOT}/admin.swf" todir="${SITE_ROOT-}sites/default/files/flash" overwrite="true"/>
	</target>
 
	<target name="deploy">
		<scp file="${SITE_ROOT-}sites/default/files/flash/admin.swf" todir="USER:PASSWORD@SERVER:/var/www/vhosts/somesite.com/httpdocs/sites/default/files/flash"/>
	</target>
 
</project>