Ant 常用语法及选项
project
项目定义,一个ant文件就是一个 project,定义了项目名称,起始位置以及默认执行的 target。
<project name="Easily" basedir="." default="build">
property
属性定义,可以定义的属性包括:文件属性、字符串定义。
<property file="build.properties"/>
<property name="WIDTH" value="1200"/>
<property name="HEIGHT" value="750"/>
<property name="PROJECT_DIR" value="${basedir}/../"/>
<property name="SOURCE_DIR" value="${PROJECT_DIR}/src"/>
taskdef
任务定义,可以理解为具体执行的任务所需要的第三方库,比如编译 as3 就需要引入 flexTasks.jar ,比如在代码中需要用到 Math 的时候,需要引入 include Math,同样的道理。
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
target
可以理解为 method,是 ant 执行的最小单位,每个 target 会有一个名称,可以主动的调用执行 。
<target name="build">
antcall
target 调用,用于执行 target 。
<antcall target="buildswf"/>
mxmlc
编译 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 外部文件引用
<mxmlc file="${SOURCE_DIR}/Easily.as"
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">
<define name="CONFIG::debug" value="true"/>
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
<compiler.debug>true</compiler.debug>
<!-- Set size of output SWF file. -->
<default-size width="${WIDTH}" height="${HEIGHT}"/>
<!-- Include all these swcs -->
<compiler.include-libraries dir="${LIBS_DIR}" append="true">
<include name="*.swc" />
<exclude name="data.swc"/>
</compiler.include-libraries>
<!-- Include the useful swcs -->
<compiler.library-path dir="${LIBS_DIR}" append="true">
<include name="*.swc"/>
</compiler.library-path>
<!-- Reference the external swcs -->
<compiler.external-library-path dir="${LIBS_DIR}" append="true">
<include name="*.swc" />
</compiler.external-library-path>
<source-path path-element="F:/My Documents/SVN/Box2D/src"/>
</mxmlc>
compc
编译 as3 项目,输出 swc 库,大部分选项都同 mxmlc ,需要注意的是 include-classes ,这个参数需要指定哪些类需要编译进 swc 中,格式是以空格为分隔符的类的字符串列表,比如: org.easily.astar.AStar org.easily.astar.BinaryHeap org.easily.astar.Grid org.easily.astar.Node
<compc output="${OUTPUT_DIR}/easily.swc"
include-classes="${CLASSES}"
optimize="true"
benchmark="true"
strict="true"
actionscript-file-encoding="utf-8"
locale="en_US"
allow-source-path-overlap="true"
use-resource-bundle-metadata="true"
incremental="false">
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
<compiler.debug>false</compiler.debug>
<show-actionscript-warnings>false</show-actionscript-warnings>
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${SOURCE_DIR}"/>
<library-path dir="${PROJECT_DIR}/libs" includes="*" append="true"/>
<source-path path-element="F:/My Documents/SVN/Box2D/src"/>
</compc>
可以将类的定义放到另外一个文件中,比如 class.properties ,定义一个属性为 CLASSES=xx xx xx,ant 是有相关的 api 可以将相关的类定义找到并处理好,只是语法过于拧巴,我写了个 python 脚本来干这个事情:
import os
def findmatch(file_name, ext, excludes):
for exclude in excludes:
if file_name.find(exclude) != -1:
return False
return file_name.endswith(ext)
def list_file(dir_name, ext, excludes):
result = []
for root, dirs, files in os.walk(dir_name):
result.extend(os.path.join(root, file_name) for file_name in files if findmatch(file_name, ext, excludes))
return result
def list_class(root, root_sep, ext, excludes):
return (format_name(root_sep, file_name, ext) for file_name in list_file(root, ext, excludes))
def format_name(root_sep, file_name, ext):
return file_name.replace(ext, "").replace(root_sep, "").replace("\\", ".")
def export_file(root_list, ext, excludes, out_file):
with open(out_file, "w") as f:
f.write("CLASSES=")
for root in root_list:
f.writelines(class_name + " " for class_name in list_class(root, root + "\\", ext, excludes))
def main():
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
执行脚本或者应用程序,可以指定应用程序和命令行参数。
<exec executable="/bin/sh">
<arg line = "-c 'php ${basedir}/../xml.php'" />
</exec>
Ant 常用语法及选项的更多相关文章
- python MVC、MTV 框架介绍 Django 模板系统常用语法
Django 框架简介一.MVC框架和MTV框架1.MVC 全名Model View Controller,是软件工程中的一种软件架构模式,把软件系统分为三个基本部分.优势: 耦合性低 重用性高 生命 ...
- MySQL的DML常用语法格式
MySQL的DML常用语法格式 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 我们知道MySQL的查询大致分为单表查询,多表查询以及联合查询.多表查询,顾名思义,就是查询的结果可能 ...
- python3+selenium常用语法汇总
Selenium常用语法总结 一.Selenium常用定位语法 1.元素定位 (1)ID定位元素: find_element_by_id(‘’) (2)通过元素的类名称定位元素: find_eleme ...
- iptables常用语法与案例
常用命令语法: [root@www ~]# iptables [-t tables] [-L] [-nv] 选项与参数: -t :后面接 table ,例如 nat 或 filter ,若省略此项目, ...
- Markdown通用的常用语法说明
前言 Markdown 是一种轻量级的 标记语言,语法简洁明了.学习容易,还具有其他很多优点,目前被越来越多的人用来写作使用. Markdown具有一系列衍生版本,用于扩展Markdown的功能(如表 ...
- Markdown简介以及常用语法
Markdown简介以及常用语法 最近发现用markdown记录东西很方便,感觉和emacs的org mode很类似,但是windows下使用emacs不是很方便.特此记录一下markdown常用的语 ...
- Sql常用语法以及名词解释
Sql常用语法以及名词解释 SQL分类: DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE) DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT) D ...
- Markdown常用语法
什么是Markdown Markdown 是一种方便记忆.书写的纯文本标记语言,用户可以使用这些标记符号以最小的输入代价生成极富表现力的文档. 通过Markdown简单的语法,就可以使普通文本内容具有 ...
- 2 hive的使用 + hive的常用语法
本博文的主要内容有: .hive的常用语法 .内部表 .外部表 .内部表,被drop掉,会发生什么? .外部表,被drop掉,会发生什么? .内部表和外部表的,保存的路径在哪? .用于创建一些临时表存 ...
随机推荐
- Duilib 开发中的小经验
# duilib开发中收集的小代码 # ## 1 窗体创建 ## - 窗体多继承于 public WindowImplBase ,简单的定义几个函数就可以实现:拖曳caption移动(设置xml窗体的 ...
- Spark之键值RDD转换(转载)
1.mapValus(fun):对[K,V]型数据中的V值map操作(例1):对每个的的年龄加2 object MapValues { def main(args: Array[String]) { ...
- C#:向exe传值
一.需求:在不同的exe程序中,提示消息框样式一致,内容不同. 二.实现: 1.提示消息框program.cs static class Program { /// <summary> / ...
- css的权重
标签的权值为1,类选择符的权值为10,ID选择符的权值最高为100.例如下面的代码: p{color:red;} /*权值为1*/ p span{color:green;} /*权值为1+1=2*/ ...
- Java,double类型转换成String,String装换成double型
今天,老师布置了小系统,银行用户管理系统,突然发现自己的基础知识好薄弱,就把这些记录一下, double类型转化string:Double.toString(double doub); String类 ...
- 20160929001 Guid生成
全局唯一标识符(GUID,Globally Unique Identifier)是一种由算法生成的二进制长度为128位的数字标识符. using System; namespace GUID测试 ...
- ZooKeeper测试笔记
1. 下载ZooKeeper.官网:http://zookeeper.apache.org 下载后解压,假定zookeeper程序目录为/home/test/zookeeper,为陈述方便此目录记为 ...
- Excel与Word套打功能使用技巧及EXCEL数据处理成绩
Excel与Word套打功能使用技巧 婚礼邀请友人参加,就需要写请柬.而且写请柬不但要求字写得端正,还不能有错别字,再加上邀请的朋友多,写请柬就是一个劳累活.这时我们利用Word的套打功能,就会让写请 ...
- XSS常用技巧
一般发现一个xss漏洞后要做的基本上就是这些: 1. 伪造请求 使用$_REQUEST或$_GET 首先我们要找找该网站使用的程序是不是在网上能找到源码,如果能找到源码的话,就去分析后台管理员更改密码 ...
- python连接mysql的驱动
对于py2.7的朋友,直接可以用MySQLdb去连接,但是MySQLdb不支持python3.x.这是需要注意的~ 那应该用什么python连接mysql的驱动呢,在stackoverflow上有人解 ...