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

落花浮王杯 提交于 2019-12-04 12:58:34

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>

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>

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!