`
keren
  • 浏览: 1560048 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Flex Builder3集成ANT,来编译自定义swc包

    博客分类:
  • Flex
阅读更多
一,首先,給flex builder安装ant插件,参照:
http://blog.jodybrewster.net/2008/04/09/installing-ant-in-flex-builder-3/
具体步骤如下:
1.  Launch Flex Builder
2. Go to Help > Software Updates > Find and Install
3. Search for new features to install, click next
4. Select “Eclipse.org update site”, click finish
5. Select “Eclipse Java Development Tools”, click next
6. Accept the license agreement, click next
7. Click finish to start download
8. Eclipse downloads Java Development Tools
9. Click “Install all” to install Java Development Tools
10. Restart the Eclipse workbench

就是要安装 Eclipse Java Development Tools这个Plugin

[参考:http://space.zdnet.com.cn/html/84/289384-2789427.html]

二,写build.xml:
<?xml version="1.0" encoding="utf-8"?>
<project name="Compc build" basedir="." default="main">
 	<!-- defines all values for the Compc compiler -->
 	<property name="FLEX_HOME" value="D:/Adobe/fb3_plugin/sdks/3.2.0"/>
	<property name="APP_ROOT" value="${basedir}"/>
	<property name="compc.exe" value="${FLEX_HOME}/bin/compc.exe"/><!-- 没用到 -->
	<property name="src-dir" value="${APP_ROOT}/src"/>
	<property name="output.dir" value="${APP_ROOT}/swc"/>
	<property name="swf.dir" value="${APP_ROOT}/bin-debug"/>
 	<property name="output.file" value="myLovo.swc"/>
	<property name="namespaces" value="http://myLovo2009"/>
	<property name="application.locale" value="zh_CN"/>
	<!-- compiled mxml/as file Name -->
	<property name="fileName" value="main" />
	<!-- compiled mxml/as file ext -->
	<property name="fileExt" value="mxml" />
	<!-- modular application's main application fileName -->
	<property name="mainApp" value="" />
	<!-- output package direction,end with / -->
	
	<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
	<taskdef resource="net/sf/antcontrib/cpptasks/antlib.xml">  
  		<!-- 如果在本地编译,那么要指定这个jar的目录<classpath>  
    		<pathelement location="D:/ant171/lib/ant-contrib-version.jar"/>  
  		</classpath>-->
	</taskdef>
	
	<target name="buildAssertsSWC">    
        <fileset id="assets.flex" dir="${src-dir}" includes="**/*.gif,**/*.jpg,**/*.png,**/*.css,**/*.swf,**/*.TTF,**/*.jpeg,**/*.xml" />    
            <pathconvert pathsep=" " property="assets.flex.output" refid="assets.flex" dirsep="/">    
                <map from="${src-dir}/" to=""/>                                       
          </pathconvert>                                     
        <echo message="...Resources being considered..."/>
	 	<!--<macrodef name="filelist"></macrodef>
	 	<macrodef name="prefixfilelist">-include-file</macrodef>--> 
        <for list="${assets.flex.output}" delimiter=" " param="asset">    
            <sequential>                                               
                <echo>Asset:  @{asset}</echo>    
                <var name="filelist_tmp" value="${filelist}"/>    
                <var name="filelist" unset="true"/>    
                <var name="filelist" value="${filelist_tmp} ${prefixfilelist} @{asset} '${src-dir-assets}/@{asset}'"/>                                                  
            </sequential>    
        </for>    
        <echo message="-output '${basedir}/flex_libs/assets.swc' ${filelist}"/>    
        <exec executable="${FLEX_HOME}/bin/compc.exe" failonerror="true">    
            <arg line="-output '${basedir}/flex_libs/assets.swc' ${filelist}"/>                                       
        </exec>
	</target>
	<!-- compile a mxml/as file -->
	<target name="mxmlc" depends="">
		<mxmlc file="${APP_ROOT}/src/${fileName}.${fileExt}" 
			output="${APP_ROOT}/${swf.dir}/${fileName}.swf" 
			actionscript-file-encoding="UTF-8" 
			keep-generated-actionscript="false" 
			incremental="true">
			<!-- Get default compiler options. -->
			<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
			<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
			<source-path path-element="${FLEX_HOME}/frameworks" />
			
			<!-- List of SWC files or directories that contain SWC files. -->
			<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
				<include name="libs" />
				<include name="/locale/${application.locale}" />
			</compiler.library-path>
			<!-- 自定义或第三方包 -->
			<compiler.library-path dir="${basedir}" append="true">  
                <include name="libs" /> 
        	</compiler.library-path>
        	<compiler.source-path path-element="${src-dir}"/><!-- ?????? -->
			<!-- Set size of output SWF file.-->
			<default-size width="1000" height="600" />
			<delete>
	            <!-- Deletes cache file -->
	            <fileset dir="${APP_ROOT}/src" includes="${fileName}*.cache" defaultexcludes="false"/>
	        </delete>
		</mxmlc>
	</target>
	<target name="main" depends="clean">  
	        <fileset dir="${src-dir}" id="src.files"> 
	            <include name="**/**"/> 
	        </fileset> 
	        <echo message="${src.files}" /> 
	        <pathconvert 
	            property="evaFramework_classes" 
	            pathsep=" " 
	            dirsep="." 
	            refid="src.files" 
	            > 
	            <map from="\" to="/"/> 
	            <map from="${src-dir}/" to=""/> 
	            <mapper> 
	                <chainedmapper> 
	                    <globmapper from="*.as" to="*"/> 
	                </chainedmapper> 
	            </mapper> 
	        </pathconvert> 
	        <echo message="${evaFramework_classes}"/> 

	     <compc output="${output.dir}/${output.file}" 
	     	locale="${application.locale}" 
	       include-classes="${evaFramework_classes}" 
	     	 optimize="true" benchmark="true" fork="true"
	     	>
	     	
	     	<!-- Specify namespaces.-->
	     	<namespace uri="${namespaces}" manifest="my-manifest.xml" />
	     	
			 <source-path path-element="${src-dir}" />
	     	<!-- add assets files:资源文件目录-->
	     	<include-file name="assets/default/icon/desktop.jpg" path="src/assets/default/icon/desktop.jpg"/>
	     	<include-file name="assets/default/main.css" path="src/assets/default/main.css"/>
	     	
	     	<!-- Namespaces to include. -->
	     	<include-namespaces uri="${namespaces}" />
	     	
	     	
			<!-- List of SWC files or directories that contain SWC files. -->
			<external-library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
				<include name="*.swc" />
				<include name="/air/*.swc" />
				<include name="/locale/${application.locale}/*.swc" />
			</external-library-path>
	     	<!-- the thirty party swc -->
			<external-library-path dir="${APP_ROOT}/libs" append="true">
				<include name="*.swc" />
			</external-library-path>
	     </compc>
	  </target>
	<target name="clean">
  		<delete dir="${output.dir}" failonerror="true"/>
  		<mkdir dir="${output.dir}"/>
	</target>
	<!-- wrapper a swf with html express-installation template-->
	<target name="wrapper" depends="clean_htmlWrapper">
		<html-wrapper title="自动生成的swf_html" width="100%" height="100%" 
			application="flexApp" swf="${fileName}" 
			version-major="9" version-minor="0" 
			version-revision="0" history="true" 
			template="express-installation" 
			output="${APP_ROOT}/${swf.dir}" />
		<!--<move file="${APP_ROOT}/${swf.dir}index.html" tofile="${APP_ROOT}/${fileName}.html" />-->
	</target>
	<!-- clean preview previous compile file -->
	<target name="clean_swf">
		<!--<delete dir="${APP_ROOT}/${package}"/>-->
		<delete>
			<fileset dir="${APP_ROOT}/${swf.dir}" includes="${fileName}*.swf" />
		</delete>
	</target>
	<!-- clean preview previous wrapper file -->
	<target name="clean_htmlWrapper">
		<delete>
			<!-- Deletes history.swf -->
			<fileset dir="${APP_ROOT}/${package}" includes="history.swf" defaultexcludes="false" />
			<!-- Deletes playerProductInstall.swf -->
			<fileset dir="${APP_ROOT}/${package}" includes="playerProductInstall.swf" defaultexcludes="false" />
			<!-- Deletes ${fileName}.html -->
			<fileset dir="${APP_ROOT}/${package}" includes="${fileName}*.html" defaultexcludes="false" />
			<!-- Deletes history.htm -->
			<fileset dir="${APP_ROOT}/${package}" includes="$history.htm" defaultexcludes="false" />
			<!-- Deletes history.js and AC_OETags.js -->
			<fileset dir="${APP_ROOT}/${package}" includes="*.js" defaultexcludes="false" />
		</delete>
	</target>
</project>







1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics