项目定义,一个ant文件就是一个project,定义了项目名称,起始位置以及默认执行的target。
属性定义,可以定义的属性包括:文件属性、字符串定义。 任务定义,可以理解为具体执行的任务所需要的第三方库,比如编译as3就需要引入flexTasks.jar,比如在代码中需要用到Math的时候,需要引入includeMath,同样的道理。 可以理解为method,是ant执行的最小单位,每个target会有一个名称,可以主动的调用执行。 target调用,用于执行target。 编译as3项目,生成swf文件,需要指定入口文件file,输出文件output。 incremental是否增量编译define编译参数 load-config项目配置文件,有需要的话可以自己编写,没有不声明也可以static-link-runtime-shared-libraries运行时库是否静态链接compiler.debug调试信息default-size缺省尺寸 compiler.include-libraries将指定目录下的swc文件编译进目标文件,不管项目中是否引用 compiler.library-path将指定目录下的swc文件引入项目中,并将引用到的部分代码编译进目标文件 compiler.external-library-path将指定目录下的swc文件引入项目中,作为外部链接,注意,运行时如果没有找到相关定义会报错source-path外部文件引用 output=\"${OUTPUT_DIR}/Easily.swf\"show-actionscript-warnings=\"false\"actionscript-file-encoding=\"UTF-8\"keep-generated-actionscript=\"true\"use-resource-bundle-metadata=\"true\"incremental=\"false\"> 编译as3项目,输出swc库,大部分选项都同mxmlc,需要注意的是include-classes,这个参数需要指定哪些类需要编译进swc中,格式是以空格为分隔符的类的字符串列表,比如:org.easily.astar.AStarorg.easily.astar.BinaryHeaporg.easily.astar.Gridorg.easily.astar.Node importosdeffindmatch(file_name,ext,excludes):forexcludeinexcludes:iffile_name.find(exclude)!=-1:returnFalsereturnfile_name.endswith(ext)deflist_file(dir_name,ext,excludes):result=[]forroot,dirs,filesinos.walk(dir_name):result.extend(os.path.join(root,file_name)forfile_nameinfilesiffindmatch(file_name,ext,excludes))returnresultdeflist_class(root,root_sep,ext,excludes):return(format_name(root_sep,file_name,ext)forfile_nameinlist_file(root,ext,excludes))defformat_name(root_sep,file_name,ext):returnfile_name.replace(ext,\"\").replace(root_sep,\"\").replace(\"\\\\\\".\")defexport_file(root_list,ext,excludes,out_file):withopen(out_file,\"w\")asf:f.write(\"CLASSES=\")forrootinroot_list:f.writelines(class_name+\"\"forclass_nameinlist_class(root,root+\"\\\\\ext,excludes))defmain():root_list=[os.getcwd()+\"\\\\..\\\\src\"]ext=\".as\"excludes=[\"Test.as\"]out_file=\"class.properties\"export_file(root_list,ext,excludes,out_file)if__name__==\"__main__\":main()exec 执行脚本或者应用程序,可以指定应用程序和命令行参数。 因篇幅问题不能全部显示,请点此查看更多更全内容