Flex 3.5, AIR swc & ANT tasks
I am stuck on Flex SDK 3.5 at work.
Today I wanted to create a code library swc file with some AIR-specific classes and I wanted to write a build file.
It seems that there isn’t an acompc-task included in the Flex 3.5 sdk (3.5.0 build 12683), so I was using the exec-task and wrote arg-tags to expand the list of included library-paths.
External-library-path is a nice alternative to library-path if you do not want to redistribute code existing in other swc files, but I got into some problems when I wanted to use -external-library-path, because the syntax apparently has to be a bit different.
This syntax is valid but doesn’t work:
<arg line='-external-library-path "path/to/my.swc"' />
This syntax is also valid, but appears to be similar to setting the attribute append to “true” in the compc ANT-task:
<arg line='-external-library-path+="path/to/my.swc"'/>
If you have tried to substitute the library-path option with external-library-path you might have found that you have to set append=”true” and apparently this is how the command-line version looks like.
September 2, 2010 at 10:35 pm
Hi Andkrup. Is there any chance of you posting a sample build.xml, in particular the part using acompc? Thanks in advance
September 4, 2010 at 7:39 am
Hi.
Sure.
Please remember to adjust the paths and the acompc executable file to your system. On windows, the executable file is acompc.bat. Mac/*nix users use the acompc.
I hope it helps
<?xml version="1.0" encoding="utf-8"?> <project name="NewLibrary" basedir="." default="Complete Distro"> <property name="FLEX_HOME" value="/Users/Shared/SDK/Flex/adobe/flex_sdk_3.5.0.12683"/> <property name="dir.build" value="${basedir}/bin"/> <property name="dir.source" value="${basedir}/src"/> <property name="dir.library" value="${basedir}/lib"/> <property name="AsDoc.exe" value="bin/asdoc"/> <property name="MXMLC" value="bin/mxmlc"/> <property name="exe.svn" value="/usr/local/bin/svn"/> <property name="dir.player" value="player/10"/> <property name="dir.frameworks" value="frameworks/libs"/> <property name="dir.docs" value="docs/asdoc"/> <target name="Complete Distro" depends="clean Complete Distro" description="Creates a public distribution without redistributing library files"> <exec executable="${FLEX_HOME}/bin/acompc" failonerror="true"> <arg line='-library-path "${FLEX_HOME}/${dir.frameworks}/flex.swc"'/> <arg line='-library-path "${FLEX_HOME}/${dir.frameworks}/framework.swc"'/> <arg line='-library-path "${FLEX_HOME}/${dir.frameworks}/rpc.swc"'/> <arg line='-library-path "${FLEX_HOME}/${dir.frameworks}/utilities.swc"'/> <arg line='-library-path "${FLEX_HOME}/${dir.frameworks}/${dir.player}/playerglobal.swc"'/> <arg line='-external-library-path+="${dir.library}/as3corelib.swc"' /> <arg line='-external-library-path+="${dir.library}/zip.swc"' /> <arg line='-external-library-path+="${dir.library}/Library.swc"' /> <arg line='-source-path "${dir.source}/"' /> <arg line='-include-sources "${dir.source}/com/electric/air/events/"' /> <arg line='-output "${dir.build}/NewLibrary.swc"'/> </exec> </target> <target name="clean Complete Distro" description="Deletes the NewLibrary.swc"> <delete> <fileset dir="${dir.build}" includes="NewLibrary.swc"/> </delete> </target> </project>September 4, 2010 at 12:53 pm
Thank you Andkrup!! Works perfectly
October 11, 2010 at 5:16 pm
Here’s a little update:
I didn’t really think about it but it is quite obvious
Since the acompc is only a script, you can of course use the normal compc ant task. The only difference is that you should load the air-config instead of the default flex-config, which is what the acompc script does.
<compc output="${dir.build}/${ant.project.name}.swc" target-player="10.0.0"> <load-config filename="${FLEX_HOME}/frameworks/air-config.xml" /> <!-- yadda yadda --> </compc>