`
jacally
  • 浏览: 766744 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

利用Ant自动编译Flex程序

阅读更多
ant是一个基于JAVA的自动化脚本引擎,脚本格式为XML。除了做JAVA编译相关任务外,ANT还可以通过插件实现很多应用的调用。

平时我们在编译Flex文件时都是使用的FlexBuilder提供的编译功能,也可以实现自动编译的功能,但如果项目一大,涉及到一些公共组件的调用比较多时,这种编译就不是很方便了.

在习惯了利用ant自动化编译部署Java应用程序的方便功能以后,自然想到也要利用ant的脚本功能进行Flex的自动编译,以下就是我写的关于编译Flex的build.xml文件(附件中有实例工程压缩文件),实现了自动编译与生成API文档的功能:

<?xml version="1.0"?>
<project name="flex_examples" basedir="../" default="compile_modified">

	<property file="./build/build.properties" />

	<!--
		Have you edit the properties file to make sure the paths are right on your system?
	-->
	<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>
	
	<!-- 
		Extension for ANT to allow for tasks like "for" and "propertyregex"
	-->
	<taskdef resource="net/sf/antcontrib/antlib.xml">
		<classpath>
			<pathelement location="libs/ant/ant-contrib.jar" />
		</classpath>
	</taskdef>
	
	<!--
		Generate the main applications using the library
	-->
	<target name="compile_modified" depends="properties">
		<!-- 
			Loop over all of the Sample applications in the mains directory,
			compile them, and place the resulting .swf next to the application
			.mxml file.
		-->
		<for param="file">
			<!-- Find the sample applications -->
			<fileset dir="${src.dir}">
				<!-- 
					The modified selector will only select files that have been
					modified since the mains target was last run. This means we
					can update a single main, then run the mains target and
					only the updated main will get recompiled.
				-->
				<modified/>
				<include name="**/*${application.name.flag}.mxml" />
				<!-- 
					For only building specific mains, comment out
					the line above, and uncomment the line below and modify
					as appropriate.
				-->
				<!--<include name="**/HorizontalAxisDataSelector_Sample.mxml" />-->
			</fileset>
					
			<sequential>
				<propertyregex property="mainApplicationName" override="yes" input="@{file}"
										regexp=".*\${file.separator}(.*)${application.name.flag}.mxml" replace="\1" />
				<propertyregex property="mainFolderName" override="yes" input="@{file}"
										regexp="(.*)\${file.separator}(.*)${application.name.flag}.mxml" replace="\1" />
		
				<exec executable="${mxmlc.exe}" dir="${basedir}">
					<arg line="'@{file}'" />
					<arg line="-o '${mainFolderName}/${mainApplicationName}${application.name.flag}.swf'" />
					
					<arg line="-l '${lib.dir}'" />
					<arg line="-l '${flexsdk.lib.dir}'" />
					<arg line="-sp '${src.dir}'" />
					
					<arg line="-optimize" />

					<arg line="-locale ${flexsdk.locale}" />
					<arg line="-l '${flexsdk.locale.dir}'" />
				</exec>
			</sequential>
		</for>
		
	</target>
	
	<!--
		Generate ASDoc output for the library
	-->
	<target name="docs" depends="properties">
		<!-- Clean out the contents of the doc directory, without deleting "docs" -->
		
		<delete includeemptydirs="true">
			<fileset dir="${docs.dir}" includes="**/*" />
		</delete>
		
		<exec executable="${asdoc.exe}" spawn="no">
			<!-- Place the documentation in the "docs" directory -->
			<arg line="-o '${docs.dir}'" />
			
			<!-- Specify the main source path as "src" -->
			<arg line="-sp '${src.dir}'" />
			
			<!-- Document all of the classes in the "src" tree -->
			<arg line="-ds '${src.dir}' " />
			
			<!-- Include the library name in the window title -->
			<arg line="-window-title '${library.name}' "/>
			
			<arg line="-templates-path '${flexsdk.templates.dir}' "/>
		</exec>
	</target>

	
</project>
分享到:
评论

相关推荐

    使用ant编译生成flex的swc文件

    这样,我们就实现了使用Ant自动化编译Flex项目,大大提高了开发效率。 总的来说,通过Ant和Flex SDK的结合,开发者可以创建定制的构建流程,包括编译、优化、打包等,适应不同项目的需求。这种方式不仅简化了大型...

    ant编译flex脚本

    利用ant编译flex脚本,可以直接在你的程序中使用。

    使用Flex Ant Tasks编译工程文件

    总的来说,“使用Flex Ant Tasks编译工程文件”意味着利用Ant的灵活性和Flex Tasks的便捷性,实现Flex项目的自动化构建,从而提高开发效率。对于大型的Flex项目,这样的构建流程显得尤为重要,因为它可以确保代码的...

    .Ant安装编译操作手册

    - **编写目的**:本文档旨在指导软件发布人员如何正确安装与配置Apache Ant,解决在安装与使用过程中可能遇到的问题,确保能够顺利地使用Ant对Flex/Java工程项目进行自动化编译与打包。 #### 二、环境说明 - **Ant...

    flex编译

    1. **Flex SDK**:Flex开发的基础是Flex Software Development Kit(SDK),这是一个免费的、开源的工具集,包含了编译Flex应用程序所需的组件。它包括ActionScript编译器(ASC)、Flex Builder编译器(mxmlc)和...

    flex ant

    在 Flex 开发中,Ant 被用来自动化编译、测试和部署过程。开发者通常会创建一个名为 `build.xml` 的 Ant 构建脚本来定义构建任务,如编译 Flex 源代码,打包 SWF 文件,或者创建 AIR 应用程序。这样的脚本可以极大地...

    Ant安装编译操作手册

    - **编写目的**: 本文档旨在指导软件发布人员如何正确安装与配置Ant,并利用它来自动化编译Flex/Java项目,进而实现项目的打包发布流程。文档的目标读者是负责项目发布的人员。 #### 二、环境说明 - **Ant版本**: ...

    Ant 当个 脚本Flex

    Ant可以通过命令行调用来执行构建脚本,而Flex SDK提供了编译Flex应用程序所需的工具。 2. **构建脚本**:Ant脚本通常以`build.xml`命名,其中包含了构建过程的详细步骤。例如,它可能包括清理旧编译产物、编译源...

    flex_ant.zip

    使用这样的Ant脚本,开发者可以轻松地在命令行上运行`ant compile`命令,从而自动编译Flex项目,无需手动操作IDE。这对于持续集成(CI)环境尤其有用,因为它可以方便地集成到自动化构建流程中。 总结起来,"flex_...

    JW flv player flex修改源码并编译

    5. **使用Ant编译**: JW FLV Player的构建过程通常由Ant脚本控制。Ant脚本(如`build.xml`)定义了编译、打包和发布任务。你可以通过运行`ant`命令来执行这些任务。例如,使用`ant compile`命令将源码编译为SWF...

    Flex builder 学习学习 2007-10-08

    10. **文档和教程**:如"Flex Ant脚本模板"和"使用Flex Ant Tasks编译flex工程"这样的资料,是学习如何有效利用Ant构建Flex项目的教程。 综上所述,2007年时的Flex Builder学习涵盖了基础的Flex编程概念、MXML和...

    专题资料(2021-2022年)FLEX提高编译效率解决方案.docx

    3. **使用 fsch 和 ant**:fsch 是一个专门用于 Flex 编译的后台服务,结合 ant 脚本,可以更高效地编译模块。在 build.xml 文件中设置好参数,通过 ant 调用 fsch 服务进行编译。这种方式产出的 swf 文件体积较小,...

    使用IntelliJ_IDEA开发Flex应用

    - `compile`:负责编译Flex应用。 - `run`:用于运行编译后的Flex应用。 3. **编写编译任务**:在`compile`任务中,通过调用`mxmlc.jar`(Flex SDK中的编译器)来进行Flex代码的编译,并设置必要的参数,如`-load-...

    flex-sdk-4.5.1.21328A.zip

    而"lib"目录则包含了编译和运行Flex应用程序所需的库文件,如SWC文件,这些预编译的库提供了Flex组件、框架和其他服务。 "runtimes"子目录是Flex SDK中的一个重要部分,它包含了Adobe AIR(Adobe Integrated ...

    Flex书籍 文档 资料(整理 非常齐全)

    1. **Flex SDK**:Flex SDK是一个免费的开发工具包,包含了编译Flex应用程序所需的所有组件,如编译器、调试器和命令行工具。它也支持Ant构建系统,方便开发者集成到现有的开发流程中。 2. **ActionScript**:...

Global site tag (gtag.js) - Google Analytics