如何自动构建 Flex 组件库? [英] How can I automate the building of a Flex component library?

查看:20
本文介绍了如何自动构建 Flex 组件库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

  1. 我创建了一个 ant 文件,可以正确加载 ant 任务库,因此可以执行 任务.
  2. 我已经找到了我需要构建的源代码,并且知道我最终想要什么样的 .swc.

我想要的是一个 ant 脚本,它可以执行与以下步骤相同的操作:

  1. 我们将项目中的所有源代码(actionscript 和 MXML)和资产构建到一个 swc 文件中.
  2. 解压并优化library.swf文件

到目前为止,我有这个:

<compc output="${DEPLOY_DIR}/${SWC_NAME}.swc"><source-path path-element="${FLEX_HOME}/frameworks"/><source-path path-element="${SRC_DIR}"/></compc></目标>

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

[compc] 加载配置文件/Applications/Adobe Flex Builder 3/sdks/3.2.0/frameworks/flex-config.xml[compc] Adob​​e Compc(Flex 组件编译器)[compc] 版本 3.2.0 构建 3958[compc] 版权所有 (c) 2004-2007 Adob​​e Systems, Inc.保留所有权利.[压缩][compc] 错误:没有指定要包含在库中[压缩][compc] 使用compc -help"获取有关使用命令行的信息.

看起来我需要枚举我想包含在库中的每个类,这太可笑了.一定会有更好的办法.我该怎么做?

解决方案

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

>

<include name="**/*.as"/><include name="**/*.mxml"/></文件集><property name="project.test.dir.fileset" refid="project.test.dir.fileset"/><!-- 将测试文件转换为编译器友好的格式.--><pathconvert property="project.test.dir.path" pathsep="" refid="project.test.dir.fileset"><复合映射器><链式映射器><globmapper from="${project.test.dir}/*" to="*"handedirsep="true"/><mapper type="package" from="*.as" to="*"/></chainedmapper><链式映射器><globmapper from="${project.test.dir}/*" to="*"handedirsep="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}"/>&依赖;</compc>

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

I would like to build a flex library project automatically instead of the current process, which involves one of our developers compiling it on his machine and then us checking in the resulting .swc file. It's gross.

I am coming at this from the perspective of a java developer, so I'm having a hard time getting the hang of the compilation tools provided in the Flex Builder 3 application, but here's what I already have:

  1. I have created an ant file that loads the ant task library correctly, and can therefore execute <mxmlc/> and <compc/> tasks.
  2. I have located the source code that I need to build, and know what sort of .swc I want to end up with.

What I want is an ant script that will do the equivalent of these steps:

  1. We build all sources (actionscript and MXML) and assets in the project into an swc file.
  2. The library.swf file is extracted and optimized

So far I have this:

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

However, it's not including any content:

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

It looks like I need to enumerate every class that I want to include in the library, which is... ludicrous. There must be a better way. How do I do this?

解决方案

You can do the following... it takes all the files from the source path and converts it to a format that the compc task can then use.

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

We use it to produce swcs for testing purposes.

这篇关于如何自动构建 Flex 组件库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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