设为首页 收藏本站
查看: 656|回复: 0

[经验分享] flex ant -- 利用apache ant編譯flex項目

[复制链接]

尚未签到

发表于 2017-1-11 10:32:51 | 显示全部楼层 |阅读模式
  首先,要使用ant編譯flex項目必須滿足以下條件
  1. java環境
  2. apache ant
  3. flex sdk
  如果具備以上條件了,那我們開始吧~@~
  

  flex sdk中帶的編譯器幾種:
  如:
  %flexsdk_home%version/asdoc 文档归档
  %flexsdk_home%version/mxmlc mxml 编译器
  %flexsdk_home%version/compc as类编译器
  我们主要是利用mxmlc进行flex编译 , 还是看例子吧
  build.xml
<?xml version="1.0"?><project name="ManangementSys" default="deploy"><!--根据操作系统设置编译环境--><condition property="platformSpecificPropertyFile" value="build.win.properties"><os family="windows" /></condition><condition property="platformSpecificPropertyFile" value="build.unix.properties"><os family="unix" /></condition><!--导入变量配置--><property file="./setup/config/${platformSpecificPropertyFile}" /><property file="./build.properties" /><target name="properties"><fail unless="asdoc.exe">The "asdoc.exe" property must be set in ${build.dir}/build.properties.</fail><fail unless="compc.exe">The "compc.exe" property must be set in ${build.dir}/build.properties.</fail><fail unless="mxmlc.exe">The "mxmlc.exe" property must be set in ${build.dir}/build.properties.</fail></target><!-- 这是一个ant扩展,使用它可以使用如"for" 和 "propertyregex"插件 --><taskdef resource="net/sf/antcontrib/antlib.xml"><classpath><pathelement location="${setup.lib}/ant-contrib-1.0b3.jar" /></classpath></taskdef><!-- Cleans project --><target name="clean"><delete dir="${build}" /><delete dir="${dist}" /></target><!-- creates buid/dist folders --><target name="init" depends="clean"><mkdir dir="${build}" /><mkdir dir="${build.config}" /><mkdir dir="${dist}" /></target><!-- compile the project --><target name="complieProject" depends="init"><!--copy配置文件到构造目录中,以备使用--><copy tofile="${build.config}/flexlib-config.xml" file="${setup.config}/flexlib-config.template.xml" overwrite="true" /><!--设置flex版本---><replace file="${build.config}/flexlib-config.xml"><replacefilter token="@FLEX_LIBS_HOME@" value="${flexsdk.lib}" /><replacefilter token="@FLEX_BUILD_VERSION@" value="${flex.version}" /></replace><!--在此进行编译--><exec executable="${mxmlc.exe}" dir="${basedir}" logerror="on"><arg line="'${src.dir}/${application.name}.mxml'" /><!--源码文件--><arg line="-o ${dist}/${application.name}.swf" /><!--编译结果输出文件--><arg line="-load-config '${flexsdk.dir}/frameworks/flex-config.xml'" /><!--加载配置,这是flex库--><arg line="-load-config ${build.config}/flexlib-config.xml" /><!--其它一些参数设置---></exec></target><!--资源copy --><target name="copyAssets" depends="init"><copydir dest="${dist}/assets" src="${src.dir}/assets"></copydir><copydir dest="${dist}/com/amusement" src="${src.dir}/com/amusement" excludes="**/*.mxml"></copydir></target><!--copy html模板--><target name="copyWebRequired"><copydir dest="${dist}" src="${setup.webrequired}" excludes="**/${html.template.file}"></copydir><copyfile dest="${dist}/index.html" src="${setup.webrequired}/${html.template.file}" /><replace file="${dist}/index.html"><replacefilter token="@FLASH_SWF@" value="${application.name}" /></replace></target><target name="test" depends="complieProject,copyAssets"><!--测试--><exec executable="${flashDebugPlayer.exe}" spawn="yes"><arg line="${dist}/${application.name}.swf" /></exec></target></project>build.unix.propertiesdeploy.webapp.home=/usr/local/tomcat/webapps/mg# The location of the Flex SDK on your system.flex.home = /opt/flexflex.version = 4.0.0# conditional compilation variables, whether you're building against flex 3 or 4# note: both variables must be set, both are actually used in the code base. They# obviously should be set to opposite values :)flex.version3 = falseflex.version4 = true# Name for the Flex compiler binaries. The path will be derived from the flex home + version.asdoc.exe.name = asdocmxmlc.exe.name = mxmlccompc.exe.name = compc# path to flash debug player binaryflashDebugPlayer.exe = flashplayer
build.win.propertiesdeploy.webapp.home=D\:\\Program Files\\Apache Foundation\\tomcat-6.0.29\\webapps\\mg# The location of the Flex SDK on your system.# flex3--# flex.home = C:/Program Files/Adobe/Flash Builder 4 Plug-in# flex.version = 4.0.0# flex 4flex.home = D:/Program Files/Adobe/Adobe Flash Builder 4flex.version = 4.0.0# conditional compilation variables, whether you're building against flex 3 or 4# note: both variables must be set, both are actually used in the code base. They# obviously should be set to opposite values :)flex.version3 = falseflex.version4 = true# name for the Flex compiler binaries. The path will be derived from the flex home + version.asdoc.exe.name = asdoc.exemxmlc.exe.name = mxmlc.execompc.exe.name = compc.exe# path to flash debug player binary# The debug player is necessary here because it writes trace statements to a flashlog.txt# file.  This allows us to examine the .txt file and determine the status of unit tests# in an automated fashion.flashDebugPlayer.exe = ${flex.home}/Player/win/FlashPlayer.exe
flexlib-config.template.xml<?xml version="1.0"?><flex-config><compiler><source-path><path-element>../../src</path-element></source-path><library-path><path-element>../../libs</path-element><path-element>@FLEX_LIBS_HOME@/libs</path-element><path-element>@FLEX_LIBS_HOME@/locale/{locale}</path-element></library-path></compiler><compiler.debug>false</compiler.debug><compiler.optimize>true</compiler.optimize><compiler.keep-as3-metadata><name>Bindable</name><name>Managed</name><name>ChangeEvent</name><name>NonCommittingChangeEvent</name><name>Transient</name></compiler.keep-as3-metadata></flex-config>  注意:
  1. 如果在项目中使用embed内嵌资源,在编译过程中出现找不到资源的错误 ,这种情况是路径不正确引起的,所在要引用资料时路径设置为从根目录开始 ,就以项目下assets文件夹下test.png为例,
  应该这样写 embed(source=''/assets/test.png") 不要写为embed(source=''assets/test.png")
  2. 需要对第个module进行编译

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-326938-1-1.html 上篇帖子: Apache带宽流量控制模块安装 mod_bw 下篇帖子: 一个apache为两个不同端口的网站提供服务
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表