<?xml version="1.0" encoding="UTF-8"?>
<!-- *************************************************************************************
		FDTKit Buildfile v3.2.9
		
		Mar 13, 2008 - jason m horwitz | Sekati LLC | sekati.com
		
		Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
		
		@see	http://fdtkit.googlecode.com/
		@see	http://inde.googlecode.com/
		@see	http://sekati.googlecode.com/		
		@see	http://sasapi.googlecode.com/
		
		@note	Targeted for INDE/FDTKit this Buildfile can be used in standard Eclipse/FDT.
		
		@info	You *must* run this Buildfile in the same JRE as the workspace. To configure
		        this: Run -> External Tools -> JRE -> Run in the same JRE as the workspace
		        
		@usage	1. Copy build.xml file to your project root directory.
				2. Copy build/build.properties file to your project/build directory.
				3. Edit the build.xml project name attribute to reflect your project name.
				4. Edit the project/build/build.properties file to reflect your project settings.
				5. Edit the build.xml "build" target to point to the appropriate compile antcall.
				6. Add the build file to eclipse via the Ant panel view.
				7. Run the "create_project_structure" task to create a generic project structure.
				
		@warn	If using the "player-preview" task to preview the compiled swf in the debug
				player you will need to add your workspace as an allowed location in the flash
				security preference panel (which will pop up) and make sure compiler.use-network
				is set false. 		
		        
     ************************************************************************************* -->

<project name="Sekati API" default="build" basedir=".">


	<!-- DEFINITIONS -->
	<property file="/Applications/inde/workspace/fdtkit/build/default.properties"/>	
	<property file="build/build.properties"/>
	
	
	<!-- RESOURCE -->
    <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
		
		
	<!-- **************************************************************** 
		 CUSTOMIZE BEGINS 
		 **************************************************************** -->
	
	
	<target name="build" description="Default Project Build" depends="verify-properties">
		<!-- COMPILE OPTION -->
		
		<antcall target="compile-flash"/>
		
		<!--
		- SELECT A COMPILE OPTION FROM THE LIST BELOW -
		<antcall target="compile-flash"/>
		<antcall target="compile-flash-fla"/>
		<antcall target="compile-flex"/>
 		<antcall target="compile-flex-debug"/>
		<antcall target="compile-swc"/>
		-->
		
		<!-- PREVIEW OPTION -->
		
		
		
		<!--
		- SELECT A PREVIEW OPTION FROM THE LIST BELOW -
		<antcall target="preview-player"/>
		<antcall target="preview-browser"/>
		<antcall target="preview-wrapper"/>
		-->
	</target>
	
	
	<!-- **************************************************************** 
		 CUSTOMIZE ENDS
		 **************************************************************** -->	
	
	
	<!-- BUILD AUTOMATION -->
	
	<target name="api-production-prep" description="Put the current build of the API into production (compile swc, asdocs, deploy via rsync and ready for svn commit)">
	 	<echo>SEKATI API :: [ Package + Deploy ] >>></echo>
	    <antcall target="compile-swc"/>
	    <antcall target="doc-asdoc"/>
	    <antcall target="deploy-project"/>	
	</target>
	
	
    <target name="automate-doc-rollout" description="A batch target to generate and deploy documentation (customize to your needs)">
    	<antcall target="doc-clean"/>
    	<antcall target="doc-asdoc"/>
        <antcall target="deploy-documentation"/>
    </target>
	
	
    <target name="automate-compile-rollout" description="A batch target to compile and deploy project (customize to your needs)">
    	<antcall target="compile-flex"/>
        <antcall target="deploy-project"/>
    </target>
	
	
	<!-- *************************************************************************************
		 							INTERNAL TARGETS BELOW			        
	     ************************************************************************************* -->
	
	
	<!-- AS3 COMPILATION -->
	
	
	<target name="compile-flex" description="mxmlc compile">
		<echo>FDTKit Flex Compiler [no-debug] -></echo>
		<antcall target="compile-mxmlc-advanced">
			<param name="compiler.debug" value="false"/>
		</antcall>
	</target>
	
		
	<target name="compile-flex-debug" description="mxmlc debug compile">
		<echo>FDTKit Flex Compiler [debug] -></echo>
		<antcall target="compile-mxmlc-advanced">
			<param name="compiler.debug" value="true"/>
		</antcall>
	</target>	
	
	
	<target name="compile-mxmlc-advanced" description="Compile project.class with the mxmlc compiler using advanced build.properties options">
		<echo>FDTKit MXMLC Compiler [advanced] -> ${project.class}: ${project.swf}</echo>
		<mxmlc 
			file="${project.class}" 
			output="${project.swf}" 
			compiler.as3="${compiler.as3}"
			compiler.optimize="${compiler.optimize}"
			compiler.strict="${compiler.strict}"
			actionscript-file-encoding="${compiler.encoding}"
			keep-generated-actionscript="${compiler.keep-generated-as}"
			incremental="${compiler.incremental}"
			benchmark="${compiler.benchmark}"
			debug="${compiler.debug}"
			use-network="${compiler.use-network}"
			warnings="${compiler.warnings}"
			default-background-color="${project.bgcolor}">
		    <default-size width="${project.width}" height="${project.height}" />
			<metadata title="${project.meta.title}" description="${project.meta.description}" date="${project.meta.date}">
				<contributor name="${project.meta.contributor}" />
				<creator name="${project.meta.creator}" />
				<publisher name="${project.meta.publisher}" />
			</metadata>
			<compiler.external-library-path dir="${lib.dir}">
			    <include name="**/*.swc" />
				<include name="${project.lib.linked0}" />
				<include name="${project.lib.linked1}" />
				<include name="${project.lib.linked2}" />					
				<exclude name="${project.lib.exclude0}" />
				<exclude name="${project.lib.exclude1}" />
				<exclude name="${project.lib.exclude2}" />
			</compiler.external-library-path>
			<load-config filename="${compiler.config}"/>
		</mxmlc>
	</target>

	
	<target name="compile-mxmlc-basic" description="Compile project.class with the mxmlc compiler using the default options">
		<echo>FDTKit MXMLC Compiler [basic] -> ${project.class}: ${project.swf}</echo>
		<exec executable="${mxmlc.exe}" failonerror="true">
			<arg line ="-output ${project.swf}" />
			<arg line ="${project.class}" />
		</exec>
	</target>
			
	
	<target name="compile-swc" description="Compile project.swc.source in to an SWC library file">
		<echo>FDTKit SWC Compiler -> ${project.swc.source}: ${project.swc}</echo>
		<compc output="${project.swc}" locale="${flex3sdk.locale}" debug="${project.swc.debug}"> 
			<source-path path-element="${src.dir}" />
			<include-sources dir="${project.swc.source}">
				<include name="*"/>
				<exclude name="**/.svn"/>
				<exclude name="${project.swc.exclude0}"/>
				<exclude name="${project.swc.exclude1}"/>
				<exclude name="${project.swc.exclude2}"/>
			</include-sources>
			<external-library-path dir="${lib.dir}" append="true">
				<include name="tweener.swc" />
			</external-library-path>
			<external-library-path dir="${flex3sdk.lib.dir}" append="true">
				<include name="flex.swc" />
				<include name="framework.swc" />
				<include name="rpc.swc" />
				<include name="utilities.swc" />
			</external-library-path>
			<metadata title="${project.meta.title}" description="${project.meta.description}" date="${project.meta.date}">
				<contributor name="${project.meta.contributor}" />
				<creator name="${project.meta.creator}" />
				<publisher name="${project.meta.publisher}" />
			</metadata>			
		</compc>
	</target>	
	
	
	<!-- IDE FLA COMPILATION -->	
	

	<target name="compile-flash" description="Compile the currently opened FLA with the Flash IDE">
		<echo>FDTKit Flash IDE Compiler -></echo>
		<echo message="|*|*|*| class cache clear | source save | compiler start |*|*|*|"/>
		<exec executable="open">
			<arg line="${compile.jsfl}"/>
		</exec>	
	</target>
				
				
	<target name="compile-flash-fla" description="Compile project.fla with the Flash IDE">
		<echo>FDTKit Flash IDE Compiler -> ${project.fla}</echo>
		<fdt.flashCompile>
	        <fileset dir="${src.dir}">
	            <include name="${project.fla}"/>
	        </fileset>
	    </fdt.flashCompile>		
	</target>
	
	
	<target name="compile-flash-lib" description="Compile all FLA's in lib.dir with the Flash IDE">
		<echo>FDTKit Flash IDE Compiler -> ${libs.dir}</echo>
	    <fdt.flashCompile>
	        <fileset dir="${lib.dir}">
	        	 <include name="*.fla"/>
	        </fileset>
	    </fdt.flashCompile>
	</target>
	
	
	<target name="compile-flash-src" description="Compile all FLA's in src.dir with the Flash IDE">
		<echo>FDTKit Flash IDE Compiler -> ${src.dir}</echo>
	    <fdt.flashCompile>
	        <fileset dir="${src.dir}">
	        	 <include name="*.fla"/>
	        </fileset>
	    </fdt.flashCompile>
	</target>	
	
	
	<target name="compile-flash-tests" description="Compile all FLA's in tests.dir with the Flash IDE">
		<echo>FDTKit Flash IDE Compiler -> ${tests.dir}</echo>
		 <fdt.flashCompile failonerror="false">
		   <fileset dir="${tests.dir}">
		    <include name="*.fla"/>
		   </fileset>
		  </fdt.flashCompile>
	</target>
	
	
	<!-- PREVIEW -->
	
	
	<target name="preview-player" description="View the project.swf in the debug Flash Player">
		<echo>FDTKit Player Preview -> ${player.args}: ${project.swf}</echo>
		<exec executable="${swfviewer.exe}" spawn="false">
			<arg line="${flashplayer.exe}"/>
			<arg line="${project.swf}"/>
		</exec>
		<!--
		<exec executable="${sys.open}" spawn="false">
			<arg line="${flashplayer.exe}"/>
			<arg line="${project.swf}"/>
		</exec>
		-->		
	</target>		

	
	<target name="preview-browser" description="View the project.preview.url in the Browser">
		<echo>FDTKit Brower Preview -> ${browser.args}: ${project.preview.url}</echo>
		<exec executable="${sys.open}" spawn="true">
			<arg line="${browser.args}"/>
			<arg line="${project.preview.url}"/>
		</exec>	
	</target>
				
	
	<target name="preview-wrapper" description="View the generated-wrapper in the Browser">
		<echo>FDTKit Wrapper Preview -> ${browser.args}: file://${TEMP_DIR}/${project.swf.prefix}/index.html</echo>
		<antcall target="generate-wrapper"/>
		<exec executable="${sys.open}" spawn="true">
			<arg line="${browser.args}"/>
			<arg line="file://${TEMP_DIR}/${project.swf.prefix}/index.html"/>
		</exec>	
	</target>	
	
	
	<!-- DOCUMENTATION -->

	
	<target name="doc-asdoc" description="Generate AS3 Documention from the src.dir using ASDoc">
		<echo>FDTKit Generating ASDoc Documentation -> ${src.dir}</echo>
		<exec executable="${asdoc.exe}" failonerror="false">
			<arg line ="-source-path ${src.dir}" />
			<arg line='-source-path ${project.lib.linked0}'/>
			<arg line='-source-path ${project.lib.linked1}'/>
			<arg line='-source-path ${project.lib.linked2}'/>
			<arg line='-external-library-path "${lib.dir}/tweener.swc"' />
			<arg line='-doc-sources ${src.dir}/.'/>
			<arg line='-warnings=${doc.asdoc.warnings}'/>
			<arg line="-templates-path '${flex3sdk}/asdoc/templates'"/>
			<arg line="-main-title ${doc.asdoc.maintitle}"/>
			<arg line="-window-title ${doc.asdoc.windowtitle}"/>
		    <arg line="-footer ${doc.asdoc.footer}"/>
			<arg line='-output ${docs.dir}'/>
			<arg line='-exclude-classes=${doc.asdoc.excludes}'/>
		</exec>
		<copy todir="${docs.dir}/images">
		  <fileset dir="${flex3sdk}/asdoc/templates/images" excludes="**/.svn"/>
		</copy>
	</target>
				
				
	<target name="doc-asdoc-graph" description="Generate an ASDoc XML file from the src.dir for use with graphviz to create dot diagrams">
		<echo>FDTKit Generating ASDoc Graph XML -> ${src.dir}</echo>
		<exec executable="${asdoc.exe}" failonerror="false">
			<arg line = "-source-path ${src.dir}" />
			<arg line='-doc-sources ${src.dir}'/>
			<arg line='-output ${docs.dir}/graph'/>
			<arg line="-keep-xml"/>
			<arg line="-skip-xsl"/>
			<arg line="-show-actionscript-warnings=false"/>
			<arg line="-templates-path '${flex3sdk}/asdoc/templates'"/>
		</exec>
	</target>
	
	<target name="doc-clean" description="Remove any existing Documentation from docs.dir">
		<echo>FDTKit Cleaning Documentation -> ${docs.dir}</echo>
		<defaultexcludes echo="true"/>
		<delete includeemptydirs="true">
			<fileset dir="${docs.dir}" includes="**/*" excludes="**/.svn"/>
		</delete>	
	</target>			
	
	
	<!-- DEPLOYMENT-->	
	
	
	<target name="deploy-project" description="Deploy the project from deploy.local.dir to the remote project server using rsync+ssh">
		<echo>FDTKit Deploying Project -> ${deploy.local.dir}</echo>
		<exec executable="${rsync.exe}">
			<arg value="-ave ssh"/>
			<arg value="--delete"/>
			<arg value="--force"/>
			<arg value="--progress"/>
			<arg value="--exclude=${deploy.local.excludes}"/>
			<arg value="${deploy.local.dir}"/>
			<arg value="${deploy.remote.user}@${deploy.remote.host}:${deploy.remote.dir}"/>
		</exec>
	</target>	
	
	
	<target name="deploy-documentation" description="Deploy the documentation from deploy.local.doc.dir to the remote documentation server using rsync+ssh">
		<echo>FDTKit Deploying Documentation -> ${deploy.local.doc.dir}</echo>
		<exec executable="${rsync.exe}">
			<arg value="-ave ssh"/>
			<arg value="--delete"/>
			<arg value="--force"/>
			<arg value="--progress"/>
			<arg value="--exclude=${deploy.local.excludes}"/>
			<arg value="${deploy.local.doc.dir}"/>
			<arg value="${deploy.remote.user}@${deploy.remote.host}:${deploy.remote.doc.dir}"/>
		</exec>
	</target>

	
	<target name="deploy-backend" description="Deploy the project backend from deploy.local.backend.dir to the remote project server using rsync+ssh">
		<echo>FDTKit Deploying Backend -> ${deploy.local.sbackend.dir}</echo>
		<exec executable="${rsync.exe}">
			<arg value="-ave ssh"/>
			<arg value="--delete"/>
			<arg value="--force"/>
			<arg value="--progress"/>
			<arg value="--exclude=${deploy.local.excludes}"/>
			<arg value="${deploy.local.backend.dir}"/>
			<arg value="${deploy.remote.user}@${deploy.remote.host}:${deploy.remote.backend.dir}"/>
		</exec>
	</target>	
	
	
	<!-- SANITY CHECK -->
	
	
	<target name="verify-properties">
		<fail unless="FDTKIT_HOME">The "FDTKIT_HOME" property must be set in build/build.properties.</fail>
	</target>
			
	
	<!-- MISCELLANY -->
	

	<target name="generate-wrapper" description="Generate a project.swf HTML wrapper in the TEMP_DIR">
		<property name="wrapper.dir" value="${TEMP_DIR}/${project.swf.prefix}"/>
		<echo>FDTKit Generating Wrapper -> ${wrapper.dir}</echo>
		<delete includeemptydirs="true" failonerror="false">
			<fileset dir="${wrapper.dir}" includes="**/*" excludes="**/.svn"/>
		</delete>
		<mkdir dir="${wrapper.dir}"/>
		<html-wrapper
			title="${ant.project.name}"
			width="${project.wrapper.width}"
			height="${project.wrapper.height}"
			bgcolor="${project.wrapper.bgcolor}"
			application="${project.wrapper.name}"
			swf="${deploy.dir}/${project.swf.prefix}"
	        version-major="${project.version.major}"
	        version-minor="${project.version.minor}"
	        version-revision="${project.version.revision}"
			history="${project.wrapper.history}"
			template="${project.wrapper.template}"
			output="${wrapper.dir}"
		/>
		<!--
		<copy todir="${wrapper.dir}">
		  <fileset file="${project.swf}" excludes="**/.svn"/>
		</copy>
		-->		
	</target>		
	
	
    <target name="create-structure" description="Create a generic project directory structure.">
    	<echo>FDTKit Creating Project Structure -></echo>
		<mkdir dir="${build.dir}"/>
    	<echo message="Creating: ${build.dir}"/>    	
		<mkdir dir="${deploy.dir}"/>
    	<echo message="Creating: ${deploy.dir}"/>
    	<mkdir dir="${deploy.admin.dir}"/>
    	<echo message="Creating: ${deploy.admin.dir}"/>
    	<mkdir dir="${deploy.assets.dir}"/>
    	<echo message="Creating: ${deploy.assets.dir}"/>
    	<mkdir dir="${deploy.css.dir}"/>
    	<echo message="Creating: ${deploy.css.dir}"/>
    	<mkdir dir="${deploy.js.dir}"/>
    	<echo message="Creating: ${deploy.js.dir}"/>
    	<mkdir dir="${deploy.php.dir}"/>
    	<echo message="Creating: ${deploy.php.dir}"/>
    	<mkdir dir="${deploy.xml.dir}"/>
    	<echo message="Creating: ${deploy.xml.dir}"/>    	
    	<mkdir dir="${docs.dir}"/>
    	<echo message="Creating: ${docs.dir}"/>
    	<mkdir dir="${lib.dir}"/>
    	<echo message="Creating: ${lib.dir}"/>
    	<mkdir dir="${lib.assets.dir}"/>
    	<echo message="Creating: ${lib.assets.dir}"/>
    	<mkdir dir="${lib.comps.dir}"/>
    	<echo message="Creating: ${lib.comps.dir}"/>
    	<mkdir dir="${lib.fonts.dir}"/>
    	<echo message="Creating: ${lib.fonts.dir}"/>
    	<mkdir dir="${lib.ia.dir}"/>
    	<echo message="Creating: ${lib.ia.dir}"/>    	
    	<mkdir dir="${tests.dir}"/>
    	<echo message="Creating: ${tests.dir}"/>
    	<mkdir dir="${src.dir}"/>
    	<echo message="Creating: ${src.dir}"/>
    	<echo message="Project Structure Created Successfully! Now refresh your project in Eclipse (right click on the project and select 'Refresh')"/>
    </target>
	
	
	<target name="sloc-count" description="Count the source lines of code in src.dir">
		<exec executable="${sloccount.sh}" />
	</target>	
	
	
	<!--
	<target name="input-test">
		<input
		    message="Do you want something?"
		    validargs="yes,no"
		    addproperty="do.delete"
		  />
		  <condition property="do.abort">
		    <equals arg1="no" arg2="${do.delete}"/>
		  </condition>
		  <fail if="do.abort">Build aborted by user.</fail>	
	</target>	
	-->
	
	
</project>