如何自动构建Flex组件库?

前端之家收集整理的这篇文章主要介绍了如何自动构建Flex组件库?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想自动构建一个flex库项目而不是当前进程,这涉及我们的一个开发人员在他的机器上编译它然后我们检查生成的.swc文件.这很糟糕.

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

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

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

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

到目前为止我有这个:

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

但是,它不包括任何内容

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

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

解决方法

您可以执行以下操作…它将从源路径中获取所有文件并将其转换为compc任务随后可以使用的格式.
  1. <fileset id="project.test.dir.fileset" dir="${project.test.dir}">
  2. <include name="**/*.as" />
  3. <include name="**/*.mxml" />
  4. </fileset>
  5. <property name="project.test.dir.fileset" refid="project.test.dir.fileset" />
  6.  
  7. <!-- Convert the test files into a compiler friendly format. -->
  8. <pathconvert property="project.test.dir.path" pathsep=" " refid="project.test.dir.fileset">
  9. <compositemapper>
  10. <chainedmapper>
  11. <globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
  12. <mapper type="package" from="*.as" to="*" />
  13. </chainedmapper>
  14. <chainedmapper>
  15. <globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
  16. <mapper type="package" from="*.mxml" to="*" />
  17. </chainedmapper>
  18. </compositemapper>
  19. </pathconvert>
  20.  
  21. <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">
  22. <source-path path-element="${project.test.dir}" />
  23. &dependencies;
  24. </compc>

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

猜你在找的Flex相关文章