随笔-193  评论-715  文章-1  trackbacks-0
ANT提供了对mxmlc命令的支持,可以直接用来编译使用Flex为UI的JavaEE应用,如果你在Flex中也使用Module来作为你每个功能的组织形式,你不妨考虑用如下脚本去编译你的应用:
<target name="compileUI" >
        
<echo message="start to compile Flex UI" />
        
<for param="file">
            
<path>
                
<fileset dir="${flexsrc.dir}">
                    
<include name="**/*.mxml" />
                
</fileset>
            
</path>
            
<sequential>        
                
<propertyregex override="yes" property="compile.target.name" input="@{file}" regexp="(.*)src(.*)(mxml)" replace="\1bin\2swf" />
               
 <mxmlc file="@{file}" output="${compile.target.name}"
                    services
="${service.file}" context-root="${context.root}">
                    
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
                    
<static-link-runtime-shared-libraries>false</static-link-runtime-shared-libraries>
                    
<source-path path-element="${flexsrc.dir}" />
                    
<!-- use incremental compiling-->
                    
<compiler.incremental>true</compiler.incremental>
                    
<compiler.debug>false</compiler.debug>
                    
                    
<!-- 指定外部依赖库文件,这些库文件将不会编译进目标SWF中 -->
                    
<compiler.external-library-path dir="${flexlib.dir}">
                        
<include name="**/*.swc" />
                    
</compiler.external-library-path>
                
</mxmlc>
                
<!-- 清除缓存文件 -->
                
<!--
                <delete file="${compile.target.name}.cache" />
                
-->
                
<echo message="Compiled @{file} =====>>   ${compile.target.name}" />
                
            
</sequential>
        
</for>

    
</target>


注意事项:
1,必须使用ant-contrib包来支持for任务,使用for任务时,别忘了如下声明:
<path id="ant.classpath">
        
<fileset dir="${ant.lib.dir}">
            
<include name="*.jar" />
        
</fileset>
    
</path>
    
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="ant.classpath" />

2,编译每个mxml时,可用propertyregex来得到output文件名,
3,source-path一定不能写错,或随便写,如果这样的话,会出现如下错误:
              Error: A file found in a source-path must have the same package structure
4,如果在运行的过程中出现Java heap size或permGen不足的情况,可以指定如下系统参数:
              ANT_OPTS=-XX:MaxPermSize=256M -Xmx1024m
posted on 2010-09-26 08:51 Robin's Programming World 阅读(3132) 评论(3)  编辑  收藏 所属分类: JavaFlex & Flash

评论:
# re: 使用ANT批量编译Flex应用和模块(Use ANT to batch compiling application and modules of Flex) 2010-11-23 16:27 | juni gao
楼主能不能给一份详细的 使用Flex为UI的JavaEE应用的build.xml文件,我是菜鸟,刚接触这个,不是很明白!谢谢您的帮忙,感激不尽!  回复  更多评论
  
# re: 使用ANT批量编译Flex应用和模块(Use ANT to batch compiling application and modules of Flex) 2012-07-05 10:52 | baiyunping333
@juni gao
把ant当什么了  回复  更多评论
  
# re: 使用ANT批量编译Flex应用和模块(Use ANT to batch compiling application and modules of Flex) 2013-03-11 20:48 | bie520
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="ant.classpath" />
这个是什么意思  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: