使用 ant mxmlc 任务将 runtime-library-path 添加到 flex 构建配置 [英] Adding runtime-library-path to flex build configuration using ant mxmlc task

查看:24
本文介绍了使用 ant mxmlc 任务将 runtime-library-path 添加到 flex 构建配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

<!-- 跳过我认为不相关的属性... --><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>

那么我会在这里遗漏什么?

谢谢

解决方案

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

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

此处的帖子上有一条评论,描述了如何包括 Mate 框架作为 RSL.我在下面添加了有趣的部分.

<块引用>

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

<属性名称=rsl-dir"/><属性名称=swc-dir"/><属性名称="swc-name"/><顺序><unzip src="@{swc-dir}/@{swc-name}.swc" dest="@{rsl-dir}" ><模式集><include name="library.swf"/></模式集></解压><move file="@{rsl-dir}/library.swf" tofile="@{rsl-dir}/@{swc-name}.swf"/></顺序></宏定义><目标名称="extract-rsls"><!-- 第三方 RSL --><create-rsl rsl-dir="${build.rsls.dir}" swc-dir="${lib.dir}" swc-name="mate"/></目标>

<块引用>

然后,您需要将此 SWF 文件作为 RSL:

<mxmlc file="${src.dir}/MyApplication.mxml" output="${build.dir}/MyApplication.swf" locale="${locale}" debug="false"><!-- Flex默认编译配置--><load-config filename="${flex.frameworks.dir}/flex-config.xml"/><!-- 主源路径--><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></目标>

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

解决方案

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>

这篇关于使用 ant mxmlc 任务将 runtime-library-path 添加到 flex 构建配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆