mike chambers | about

Example : Using ANT with COMPC to compile SWCs

Friday, May 19, 2006

Following up on my previous post on how to use compc to compile SWCs, here is an ANT build file that calls compc to compile a SWC:

<?xml version="1.0" ?>
<project default="main">
	<property name="base" value="../" />
	<property name="componentName" value="MyWindow" />
	<property name="swcFile" value="${componentName}.swc" />
	<property name="manifest" value="${base}manifest.xml" />
	<property name="namespace" value="http://www.adobe.com/2006/foo" />

	<available property="swc.exists" file="${swcFile}"/>
	
	<target name="main" depends="init, compile">
	</target>
	
	<target name="init" if="swc.exists">
		<delete file="${swcFile}" />
	</target>

	<target name="compile" description="Compile SWC.">
		<echo>Building ${swcFile}</echo>
		<exec dir="." executable="cmd" failonerror="true">
		    <arg line="/c compc -namespace ${namespace} ${manifest} 
		        -source-path ${base}
		    	-include-namespaces ${namespace} -include-classes mx.containers.MyWindow
		    	-include-file MyWindow.png ${base}mx/containers/MyWindow.png 
				-output='${swcFile}'"/>
		</exec>        
	</target>
	
</project>

Put this in a file called build.xml, and run ant in the same directory.

twitter github flickr behance