使用ant mxmlc任务将runtime-library-path添加到flex构建配置

时间:2011-02-09 17:37:18

标签: flex ant mxmlc

我正在尝试构建一个flex项目,将其链接到一些RLS。在Flex Builder中设置项目时,相应的“构建配置”(我通过将-dump-config添加到编译器选项中获得)生成(除此之外)这样的标记:

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

现在,我正在尝试使用mxmlc ant任务构建项目,但我似乎无法添加对共享库的任何引用。我认为这样的事情会有所帮助,但事实并非如此:

<!-- 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>

那么我在这里可以缺少什么?

由于

3 个答案:

答案 0 :(得分:9)

您需要通过“runtime-shared-library-path”元素上的“path-element”属性指定自定义库的SWC路径,并在“url”中定义“rsl-url”指向SWF的元素。请注意,每个自定义RSL都需要这样做。

要实现这一点,您需要解压缩SWC并从中提取SWF,以便编译器可以将其复制到输出文件夹。

对帖子here发表了评论,描述了如何将Mate框架作为RSL包含在内。我在下面添加了有趣的部分。

  

首先,您必须自己从SWC文件中提取SWF。

<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>
  

然后,您需要将此SWF文件作为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 :(得分:1)

我猜你错过了路径元素

        <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>

答案 2 :(得分:0)

你可能会发现这个xsl很有用。您可以从ant调用它并从您的.actionScriptProperties文件生成RSL条目。我希望这有助于每个人通过RSL地狱!见这里:

    <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>