如何自动构建Flex组件库?

时间:2009-09-08 19:27:26

标签: flex ant flex3 adobe flexbuilder

我想自动构建一个flex库项目而不是当前进程,这涉及我们的一个开发人员在他的机器上编译它然后我们检查生成的.swc文件。这很糟糕。

我是从Java开发人员的角度来看这个,所以我很难掌握Flex Builder 3应用程序中提供的编译工具,但这就是我已有的:

  1. 我创建了一个正确加载ant任务库的ant文件,因此可以执行<mxmlc/><compc/>任务。
  2. 我找到了我需要构建的源代码,并且知道我想要最终使用什么类型的.swc。
  3. 我想要的是一个蚂蚁脚本,它将完成以下步骤:

    1. 我们将项目中的所有源(actionscript和MXML)和资产构建到swc文件中。
    2. 提取并优化了library.swf文件
    3. 到目前为止,我有这个:

      <target name="compile-component" depends="init">
        <compc output="${DEPLOY_DIR}/${SWC_NAME}.swc">
          <source-path path-element="${FLEX_HOME}/frameworks"/>
          <source-path path-element="${SRC_DIR}"/>
        </compc>
      </target>
      

      但是,它不包含任何内容:

      [compc] Loading configuration file /Applications/Adobe Flex Builder 3/sdks/3.2.0/frameworks/flex-config.xml
      [compc] Adobe Compc (Flex Component Compiler)
      [compc] Version 3.2.0 build 3958
      [compc] Copyright (c) 2004-2007 Adobe Systems, Inc. All rights reserved.
      [compc] 
      [compc] Error: nothing was specified to be included in the library
      [compc] 
      [compc] Use 'compc -help' for information about using the command line.
      

      看起来我需要枚举我想要包含在库中的每个类,这是......荒谬的。肯定有更好的办法。我该怎么做?

3 个答案:

答案 0 :(得分:12)

您可以执行以下操作...它会从源路径中获取所有文件并将其转换为compc任务随后可以使用的格式。

<fileset id="project.test.dir.fileset" dir="${project.test.dir}">
    <include name="**/*.as" />
    <include name="**/*.mxml" />
</fileset>
<property name="project.test.dir.fileset" refid="project.test.dir.fileset" />

<!-- Convert the test files into a compiler friendly format. -->
<pathconvert property="project.test.dir.path" pathsep=" " refid="project.test.dir.fileset">
    <compositemapper>
        <chainedmapper>
            <globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
            <mapper type="package" from="*.as" to="*" />
        </chainedmapper>
        <chainedmapper>
            <globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
            <mapper type="package" from="*.mxml" to="*" />
        </chainedmapper>
    </compositemapper>
</pathconvert>

<compc headless-server="true" default-frame-rate="${flex.default-frame-rate}" debug="${flex.compiler.debug.mode}" output="${build.swc.dir}/${test.component.name}.swc" include-classes="${project.test.dir.path}" directory="false">
    <source-path path-element="${project.test.dir}" />
    &dependencies;
</compc>

我们使用它来生成swcs用于测试目的。

答案 1 :(得分:10)

幸运的是,我刚刚解决了这个问题,正在寻找另一个问题的答案!

    <compc output="${basedir}/mySwc.swc" locale="en_US">
        <source-path path-element="${basedir}/src/main/flex"/>
        <include-sources dir="${basedir}/src/main/flex" includes="*" />
        <load-config filename="${basedir}/fb3config.xml" />
    </compc>

源路径是告诉它在尝试解析各种引用时要注意什么的必要条件。 include-sources告诉它要包含哪些来源(显然在这种情况下所有来源)。 load-config只是Flex Builder的-dump-config输出。

希望这会有所帮助!!

答案 2 :(得分:1)

您可以使用Maven。它是一个配置管理工具,而不仅仅是一个构建工具。它确实依赖于您的项目有一个清单文件。