Flex Ant flexTasks, Manifests and Library Includes

Flex Ant flexTasks, Manifests and Library Includes

I recently was working on a framework project where one of our front-end developers had written several UI components in Flash Profressional and compiled them into a SWC for me to leverage in an ActionScript project in Flash Builder.  Aside from the compiled SWF, we also had to deliver a SWC to third-party vendors that were developing content against our framework.  The SWC had to include a small subset of event classes from the ActionScript project along with the UI components library from my front-end dev.

The first step was to leverage the flexTasks Ant library included with the Flex SDK to use the compc task.  This is simple enough by specifying the classpath to the flexTasks.jar.  The next step was to create a manifest file specifying the classes in my ActionScript project that should be included in the SWC.  This involves defining a namespace for the manifest, then including the namespace in the compc task.  The final step was including the externally compiled SWC for the UI components.  As simple as it turned out to be, this was a much more difficult task to accomplish, primarily because of the lack of good documentation and examples from Adobe.

Below are examples of the manifest and ant builder files I ended up using for the project.  Keep in mind some variables Ant variables are defined outside of the builder file itself as Ant properties in the builder launch configuration setup in Eclipse.


<?xml version="1.0"?> 
    <component class="com.genuinejd.events.NavEvent"/> 
    <component class="com.genuinejd.events.LayoutEvent"/> 
    <component class="com.genuinejd.events.ReferenceEvent"/> 
    <component class="com.genuinejd.events.ModalEvent"/> 


<?xml version="1.0" encoding="UTF-8"?>
<project name="SWC Builder" basedir=".">   
    <property name="SOURCE_DIR" value="${basedir}/src" />
    <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> 
    <target name="main"> 
        <compc output="${OUTPUT_DIR}/Lib.swc" >
            <source-path path-element="${SOURCE_DIR}/"/> 
            <namespace uri="http://genuinejd.com/2011" manifest="${basedir}/manifest.xml" />
            <compiler.include-libraries dir="${SOURCE_DIR}/../libs" append="true">
                <include name="UI_controls.swc" />
    <target name="clean"> 
            <fileset dir="${OUTPUT_DIR}" includes="Lib.swc"/>