zoukankan      html  css  js  c++  java
  • Flex Ant脚本模板

    Flex Ant脚本模板 

    什么是 Flex Ant Tasks

    Ant (Another Neat Tool) 是一种脚本编写工具,可以使用它为项目创建自动化构建流程。它起初是为 Java 项目创建的。它使用基于 XML 的语法列出脚本文件中的目标和依赖性,并用命令行调用脚本。

    以下是示例任务的简要列表,您可以在您的项目中使用此ANT脚本模板实现构建流程自动化:

    1. 编译 Flex 应用程序、模块和组件库

    2. 使用和部署 RSL

    3. 使用 ASDoc 创建项目文档

    4. 为项目的输出 SWF 文件创建 HTML 打包程序

    Flex Ant Tasks 包括 mxmlc 和 compc 编译器任务,它们扩展了 Java Ant Tasks。因此,您可以根据需要使用 Java Ant Tasks 的任何可用属性。

     

    脚本模板:

    build.properties文件:

    # change this to your Flex SDK directory path
    FLEX_HOME= D:/Program Files/Adobe Flash Builder 4/sdks/4.1.0
    
    # this points to your project's src directory
    # {$basedir} is a default variable that can be used in any Ant script
    # and it points to the project's root folder
    SRC_DIR =${basedir}/src
    
    # points to the project's libs directory
    LIBS_DIR =${basedir}/libs
    
    # this is the folder we want to publish the swf to
    DEPLOY_DIR = ${basedir}/DEPLOY
    
    # defines the Flex framework files location
    FLEX_FRAMEWORK = ${FLEX_HOME}/frameworks/libs
    
    # this property defines the doc directory, which will store your created ASDocs later in the article
    DOC_DIR =${basedir}/DOC
    
    # defines the title for your ASDoc pages
    DOC_TITLE ="Your doc title"
    
    # defines the footer for your ASDoc pages
    DOC_FOOTER = "Copyright 2010 My Company"
    
    # points to your asdoc.exe for ASDoc creation later
    asdoc.exe =${FLEX_HOME}/bin/asdoc.exe

    注:asdoc.exe在不同操作系统下值不同,在Flash和AIR程序下值也不同

    如Windows下的AIR程序时,其值为aasdoc.bat

     

    build.xml文件:

    <project name="Flex Ant Tasks Build Script" default="compile flex ant tasks project">
     
    	<!-- load previously defined configuration properties file -->
    	<property file="build.properties" />
    	
    	<!-- points to our flexTasks.jar we copied to the libs folder to distribute with the project -->
    	<taskdef resource="flexTasks.tasks" classpath="${basedir}/libs/flexTasks.jar"/> 
    	
    	<target name="compile flex ant tasks project" depends="init, compile flex project, build doc, copyRSLs, wrapper, createSWC" />	
    	
    	<!-- delete and recreate the DEPLOY and DOC dirs -->
    	<target name="init">
    		<delete dir="${DEPLOY_DIR}" />
    		<mkdir dir="${DEPLOY_DIR}" />	
    		
    		<delete dir="${DOC_DIR}" />
    		<mkdir dir="${DOC_DIR}" />
    	</target>
    
    	<!-- ASDoc creation -->
    	<target name="build doc" depends="init">
    		<exec executable="${asdoc.exe}" failonerror="true">
    			<arg line='-doc-sources ${SRC_DIR}' />
    			<arg line='-external-library-path ${LIBS_DIR}' />
    			<arg line='-warn-level-not-supported=false'/>
    			<arg line='-main-title ${DOC_TITLE}' />
    			<arg line='-window-title ${DOC_TITLE}' />
    			<arg line='-footer ${DOC_FOOTER}' />
    			<arg line='-output ${DOC_DIR}' />
    		</exec>
    	</target>
    	
    	<!-- Build and output the Main.swf-->
    	<target name="compile flex project" depends="init">
    		<mxmlc file="${SRC_DIR}/Main.mxml" output="${DEPLOY_DIR}/Main.swf">
    	        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
    	        <source-path path-element="${FLEX_HOME}/frameworks"/>
    			<compiler.debug>false</compiler.debug>
    			
    			<runtime-shared-library-path
    				path-element="${FLEX_FRAMEWORK}/framework.swc">
    				<url rsl-url="framework_4.1.0.16076.swf"/>
    				<url rsl-url="framework_4.1.0.16076.swz"/>
    			</runtime-shared-library-path>			
    			
    		</mxmlc>
    	</target>
    	
    	<!-- HTML Wrapper -->
    	<target name="wrapper">
            <html-wrapper 
                title="Flex Ant Tasks Part II"
                file="flext_ant_pt_II_tasks.html"
                height="500"
                width="500"
                bgcolor="#000000"
                application="Main"
                swf="Main"
                version-major="9"
                version-minor="0"
                version-revision="0"
                history="true"
                output="${DEPLOY_DIR}"/>
    	</target>
    	
    	<!-- create SWC -->
    	<target name="createSWC">
    		<compc 
    	        output="${DEPLOY_DIR}/MyComps.swc"
    	        include-classes="com.pxldesigns.flexTasks.LabelBuilder">
    	        <source-path path-element="${SRC_DIR}"/>
    		</compc>
    	</target>
    	
    	<!-- copy only the Flex Framework files into the DEPLOY_DIR to use for RSLs --> 	
    	<target name="copyRSLs">
    		<copy todir="${DEPLOY_DIR}" file="${FLEX_HOME}/frameworks/rsls/framework_4.1.0.16076.swf"/>
    		<copy todir="${DEPLOY_DIR}" file="${FLEX_HOME}/frameworks/rsls/framework_4.1.0.16076.swz"/>		
    	</target>	
    </project>
    

    注:

    1. flexTasks.jar文件在不同的SDK下是不同的,确保工程libs目录下的与{SDK}\ant\lib下的相同。

    2. CopyRSLs Task在不同的SDK下,其copy的文件是不同的。另外CopyRSLs Task copy的文件应与compile flex project task下的保持一致。

  • 相关阅读:
    关于这个 blog
    P6499 [COCI2016-2017#2] Burza 题解
    CF1172F Nauuo and Bug 题解
    CF1479D Odd Mineral Resource 题解
    CF1442E Black, White and Grey Tree 题解
    CF1442D Sum 题解
    CF1025D Recovering BST 题解
    CF1056E Check Transcription 题解
    CF1025F Disjoint Triangles 题解
    红包算法的PHP实现
  • 原文地址:https://www.cnblogs.com/god_bless_you/p/1784114.html
Copyright © 2011-2022 走看看