Adding runtime-library-path to flex build configuration using ant mxmlc task

antapache-flexmxmlc

I'm trying to build a flex project, linking it to some RLSs. When setting up the project in Flex Builder, the corresponding "build configuration" (that I got by adding -dump-config to the compiler options) generates (among other things) a tag like this :

<runtime-shared-libraries>
  <url>some-lib.swf</url>
  <url>some-other-lib.swf</url>
</runtime-shared-libraries>

Now, I am trying to build the project using mxmlc ant task, but I can't seem to add any reference to a share-library. I thought something like this would have help, but it didin't:

<!-- Skipping attributes that I don't think are relevant ... -->
<mxmlc ....>
 ...
 <runtime-shared-library-path>
<url rsl-url="some-lib.swf"></url>
<url rsl-url="some-other-lib.swf"></url>
 </runtime-shared-library-path>
</mxmlc>

So what could I be missing here ?

Thanks

Best Answer

You will need to specify the path to the SWC of your custom libraries via the "path-element" attribute on the "runtime-shared-library-path" element and define the "rsl-url" in the "url" element which points to the SWF. Note that this is needed for each custom RSL individually.

To achieve this you'll need to unpack the SWC and extract the SWF from it so that the compiler can copy it to the output folder.

There is a comment on a post here that describes how to include the Mate framework as an RSL. I added the interesting part below.

First, you have to extract the SWF from the SWC file yourself.

<macrodef name="create-rsl">
  <attribute name="rsl-dir" />
  <attribute name="swc-dir" />
  <attribute name="swc-name" />
  <sequential>
    <unzip src="@{swc-dir}/@{swc-name}.swc" dest="@{rsl-dir}" >
      <patternset>
        <include name="library.swf" />
      </patternset>
    </unzip>
    <move file="@{rsl-dir}/library.swf" tofile="@{rsl-dir}/@{swc-name}.swf"/>
  </sequential>
</macrodef>

<target name="extract-rsls">
  <!-- Third parties RSLs -->
  <create-rsl rsl-dir="${build.rsls.dir}" swc-dir="${lib.dir}" swc-name="mate" />
</target>

Then, you need to put this SWF file as a RSL:

<target name="compile">
  <mxmlc file="${src.dir}/MyApplication.mxml" output="${build.dir}/MyApplication.swf" locale="${locale}" debug="false">
    <!-- Flex default compile configuration -->
    <load-config filename="${flex.frameworks.dir}/flex-config.xml" />

    <!-- Main source path -->
    <source-path path-element="${src.dir}" />

    <runtime-shared-library-path path-element="${lib.dir}/mate.swc">
      <url rsl-url="rsls/mate.swf" />
    </runtime-shared-library-path>
  </mxmlc>
</target>
Related Topic