如何自动构建 Flex 组件库?

发布于 2024-08-04 03:26:07 字数 1281 浏览 3 评论 0原文

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

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

  1. 我创建了一个 ant 文件,正确加载ant任务库,因此可以执行任务。
  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>

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

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

抹茶夏天i‖ 2024-08-11 03:26:07

您可以执行以下操作...它从源路径获取所有文件并将其转换为 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>

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

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.

手长情犹 2024-08-11 03:26:07

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

    <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 输出。

希望这有帮助!

Lucky for you I JUST solved this problem and was looking for the answer to another problem!

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

The source-path is necessary to tell it what to look at when trying to resolve various references. The include-sources tells it which sources to include (obviously in this case all of them). The load-config is just the -dump-config output from Flex Builder.

Hope this helps!!

任性一次 2024-08-11 03:26:07

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

You can use Maven. It's a configuration management tool rather than just a build tool. It does rely on your project having a manifest file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文