如何自动构建Flex组件库?

Chr*_*s R 8 apache-flex ant adobe flexbuilder flex3

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

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

  1. 我创建了一个正确加载ant任务库的ant文件,因此可以执行<mxmlc/>和执行<compc/>任务.
  2. 我找到了我需要构建的源代码,并且知道我想要最终使用什么类型的.swc.

我想要的是一个ant脚本,它将完成以下步骤:

  1. 我们将项目中的所有源(actionscript和MXML)和资产构建到swc文件中.
  2. 提取并优化library.swf文件

到目前为止我有这个:

<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>
Run Code Online (Sandbox Code Playgroud)

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

[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.
Run Code Online (Sandbox Code Playgroud)

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

Gre*_*die 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>
Run Code Online (Sandbox Code Playgroud)

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


小智 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>
Run Code Online (Sandbox Code Playgroud)

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

希望这可以帮助!!