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

6k views Asked by At

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

3

There are 3 answers

2
Christophe Herreman On 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>
1
kbgn On

I guess you are missing the path-element

        <runtime-shared-library-path path-element="${FLEX_FRAMEWORK}/framework.swc">
            <url rsl-url="framework_3.4.1.10084.swf"/>
            <!--<url rsl-url="datavisualization_3.2.0.3958.swf"/>-->
        </runtime-shared-library-path>
0
user2018819 On

You may find this xsl useful. You can call it from ant and generate your RSL entries from you .actionScriptProperties file. I hope this helps everyone going through RSL hell!!! See here:

    <mxmlc output="${{dist.dir}}/${{inputMXML}}.swf"
                    file="${{src.dir}}/${{inputMXML}}.mxml"
                    locale="${{compiler.locale}}"
                    use-network="${{compiler.use-network}}"
                    debug="false"
                    optimize="true"
                    incremental="false">
                 <load-config filename="${{FLEX_HOME}}/frameworks/flex-config.xml"/>

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

                 <!-- Project RSLs -->
            <xsl:for-each select="//libraryPath/libraryPathEntry">
                 <xsl:if test="@linkType = '1'">
           <compiler.library-path>
                 <!--  substring before last '/' -->
                 <xsl:attribute name="dir">
                        <xsl:call-template name="substring-before-last">
                                     <xsl:with-param name="list" select="@path" />
                                     <xsl:with-param name="delimiter" select="'/'" />
                              </xsl:call-template>
                 </xsl:attribute>
                 <xsl:attribute name="append">true</xsl:attribute>
                       <xsl:element name="include">
                              <xsl:attribute name="name">
                                            <!--  substring after last '/' -->
                                            <xsl:call-template name="substring-after-last">
                                              <xsl:with-param name="string" select="@path" />
                                              <xsl:with-param name="delimiter" select="'/'" />
                                            </xsl:call-template>
                              </xsl:attribute>
                       </xsl:element>
           </compiler.library-path>
                 </xsl:if>
         </xsl:for-each>



                 <!-- Framework RSLs. Note: Order is important. Also note: swz comes
                      first. This is the signed version of the library which once
                      downloaded can be used cross-domain, possibly saving bandwidth -->
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/textLayout.swc">
                       <url rsl-url="textLayout_2.0.0.232.swz"/>
                       <url rsl-url="textLayout_2.0.0.232.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/framework.swc">
                       <url rsl-url="framework_4.6.0.23201.swz"/>
                       <url rsl-url="framework_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/osmf.swc">
                       <url rsl-url="osmf_1.0.0.16316.swz"/>
                       <url rsl-url="osmf_1.0.0.16316.swf"/>

                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/charts.swc">
                       <url rsl-url="charts_4.6.0.23201.swz"/>
                       <url rsl-url="charts_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/rpc.swc">
                       <url rsl-url="rpc_4.6.0.23201.swz"/>
                       <url rsl-url="rpc_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/mx/mx.swc">
                       <url rsl-url="mx_4.6.0.23201.swz"/>
                       <url rsl-url="mx_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/spark.swc">
                       <url rsl-url="spark_4.6.0.23201.swz"/>
                       <url rsl-url="spark_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/advancedgrids.swc">
                       <url rsl-url="advancedgrids_4.6.0.23201.swz"/>
                       <url rsl-url="advancedgrids_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/sparkskins.swc">
                       <url rsl-url="sparkskins_4.6.0.23201.swz"/>
                       <url rsl-url="sparkskins_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>
                 <runtime-shared-library-path path-element="${{FLEX_HOME}}/frameworks/libs/spark_dmv.swc">
                       <url rsl-url="spark_dmv_4.6.0.23201.swz"/>
                       <url rsl-url="spark_dmv_4.6.0.23201.swf"/>
                 </runtime-shared-library-path>

                 <!-- Project RSLs -->
                 <!-- Flex Ant Task Shortcoming. -->
                 <xsl:for-each select="//libraryPath/libraryPathEntry">
                 <xsl:if test="@linkType = '4'">
                         <runtime-shared-library-path>
                               <xsl:attribute name="path-element">
                                      <xsl:value-of select="@path" />
                               </xsl:attribute>
                       <xsl:element name="url">
                              <xsl:attribute name="rsl-url">
                                    <xsl:value-of select="crossDomainRsls/crossDomainRslEntry/@rslUrl" />
                              </xsl:attribute>
                       </xsl:element>
                         </runtime-shared-library-path>
                 </xsl:if>
         </xsl:for-each>
    </mxmlc>