Flex Library ANT 编译

搜集了网上的资源并根据自己项目情况整理,做个记录和备份。最核心的难点在与namespace的添加。不过知道了以后会发现原来如此简单。DUANG ! ! !


build.properties

######################################

## Author ganxz
## Date 2016/04/22

######################################

######################################

## Flex 基础信息配置

######################################

FLEX_HOME=D:/Program Files (x86)/Adobe/Adobe Flash Builder 4.6/sdks/4.6.0
LOCALE = en_US,zh_CN

######################################

## Flex Flex Library Project配置

######################################
# 库编译公共配置/ 定义目标编译结果路径
DIST_HOME=dist
DIST_HOME_SRC=dist/src
DIST_HOME_BIN=dist/bin
DIST_HOME_LIBS=dist/libs

#具体库项目配置
PROJECT_HOME=D:/workspace_ant
LIBS=UILib2,UILib



OUTPUT_DIR=output

build.xml

<?xml version="1.0"?>
 <project name="xxxxProjectFlex" default="build" basedir=".">
 	<property file="build.properties" />
 	<taskdef name="mxmlc" classname="flex.ant.MxmlcTask" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
 	<taskdef name="compc" classname="flex.ant.CompcTask" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
 	<taskdef name="acompc" classname="flex.ant.CompcTask" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> 	
 	<!-- 定义目标编译结果路径 -->
 	<property name="dist.home" value="./dist" />
 	<!-- 定义源码路径  -->

 	<target name="build">
 		<antcall target="init" />
 		<antcall target="UILib" />
 		<!-- 
 			<antcall target="clean" />
	 		<antcall target="compile" />
	 		<antcall target="wrapper" /> 
 		-->
 		 
 	</target>
 	
 	<!-- 初始化工程 -->
 	<target name="init">
 		<echo message="Flex SDK Home: ${FLEX_HOME}" />
 		<delete dir="${DIST_HOME}" />
 		<mkdir dir="${DIST_HOME}" />
 		<!-- <copy todir="${dist.home.src}">
 			<fileset dir="${project.home.src}" />
 		</copy>
 		<copy todir="${dist.home.libs}">
 			<fileset dir="${project.home.libs}" />
 		</copy>-->
 	</target>
 	
 	<!-- 编译Flex Library Project项 -->
 	<target name="<span style="font-family: Arial, Helvetica, sans-serif;">UILib</span><span style="font-family: Arial, Helvetica, sans-serif;">" ></span>
 	<echo message="star complie Flex Library Project..." />
 	<echo message="build ${DIST_HOME_LIBS}/UILib.swc" /> 	
    	<compc output="${DIST_HOME_LIBS}/UILib.swc"
 			locale="${LOCALE}"
 			debug="false" 
 			incremental="true">
    	    <namespace uri="library://ns.adobe.com/flashx/textLayout" manifest="${flexlib}/projects/textLayout/manifest.xml"/>      	      
    	    <namespace uri="http://www.adobe.com/2006/airmxml" manifest="${flexlib}/projects/airframework/manifest.xml"/>  
    	    <namespace uri="http://www.adobe.com/2006/airspark" manifest="${flexlib}/projects/airspark/manifest.xml"/>  
    	    <namespace uri="http://www.adobe.com/2006/rpcmxml" manifest="${flexlib}/projects/rpc/manifest.xml"/>  
    	    <namespace uri="http://ns.adobe.com/2009/mx-mxml" manifest="${flexlib}/projects/mx/manifest.xml"/>  
    	    <namespace uri="http://www.adobe.com/2006/advancedgridsmxml" manifest="${flexlib}/projects/advancedgrids/manifest_advancedgrids.xml"/>  
    	    <namespace uri="http://www.adobe.com/2006/charts" manifest="${flexlib}/projects/charts/manifest_charts.xml"/>      			  
    	    <namespace uri="http://www.adobe.com/2006/mxml" manifest="${flexlib}/mxml-manifest.xml"/>  
    	    <namespace uri="library://ns.adobe.com/flex/spark" manifest="${flexlib}/projects/spark/manifest.xml"/>  
    	    <namespace uri="library://ns.adobe.com/flex/mx" manifest="${flexlib}/mxml-manifest.xml"/>  
    	    <namespace uri="library://ns.adobe.com/flex/spark-mobilecomponents" manifest="${flexlib}/projects/mobilecomponents/manifest.xml"/>  
    	    <namespace uri="library://ns.adobe.com/flex/spark-dmv" manifest="${flexlib}/projects/spark_dmv/manifest_spark_dmv.xml"/> 
    		
    		<!-- 自定义的namespace -->
    		<namespace uri="library://ns.adobe.com/flex/my"  manifest="${PROJECT_HOME}/UILib/src/manifest.xml"/>
    		<include-namespaces uri="library://ns.adobe.com/flex/my"/>
    					
    		<load-config filename="${FLEX_HOME}/frameworks/air-config.xml"/>
 			<!-- 指定项目的源码目录 -->
 			<source-path path-element="${PROJECT_HOME}/UILib/src" />
 			<!-- 指定编译的文件列表 -->
 			<include-sources dir="${PROJECT_HOME}/UILib/src">
 				<include name="**/*.mxml" />
 				<include name="**/*.as" />
 			</include-sources>
 			<!-- 将Flex SDK 作为外部库进行引用 -->
 			<compiler.external-library-path dir="${FLEX_HOME}/frameworks">
 				<include name="**/*.swc" />
 			</compiler.external-library-path>
 			<!-- 添加项目中的SWC包,请注意这里是外部 -->
 			<compiler.external-library-path dir="${PROJECT_HOME}/UILib/libs">
 				<include name="**/*.swc" />
 			</compiler.external-library-path>
 		</compc>
 		<!-- 删除缓存文件 -->
    	<delete>
 			<fileset dir="${DIST_HOME_LIBS}" includes="*.cache" />
 		</delete>
 		<echo message="complier Flex Library Project finished!" />
 	</target>
 </project>


猜你喜欢

转载自blog.csdn.net/ganxunzou/article/details/51224557