ant是一个脚本构建工具,可能就是持续集成里面所需要的构建工具。
如果使用eclipse,里面会自带有ant工具,不需要再安装了,创建一个build.xml(或者其他的名字都可以),使用ant来运行就可以了
如果使用的命令行来运行ant,需要安装的步骤如下:
(1)下载ant,解压,无需安装过程。
(2)将ant的bin目录加入到系统的环境变量path中。
(3)运行ant,可以查看是否加成功了。
(4)在cmd中,将目录切换到工程所在的build.xml目录下,运行ant(这里默认为build.xml文件,还可以自己制定需要的文件)
关于build.xml文件的目录结构
...
一些需要记录的东西:
(1)运行一个java程序的定义:
如果引用了第三方的包,那么需要在classpathref中定义,否则会提示错误信息。
(2)定义一个时间戳
只要定义了这个,就定义了三个参数:DSTAMP,TSTAMP,TODAY,在下面的内容中就可以使用${DSTAMP}等了。在上面我们定义了自己的参数TIME,可以使用。这个时间戳在整个build过程中是不变的。
(3)在命令行里运行的参数
命令行选项总结:
ant [options] [target [target2 [target3] ...]]
Options:
-help print this message
-projecthelp print project help information
-version print the version information and exit
-quiet be extra quiet
-verbose be extra verbose
-debug print debugging information
-emacs produce logging information without adornments
-logfile file use given file for log output
-logger classname the class that is to perform logging
-listener classname add an instance of class as a project listener
-buildfile file use specified buildfile
-find file search for buildfile towards the root of the filesystem and use the first one found
-Dproperty=value set property to value
(4)一些ant自带的内置变量
os.name: 操作系统的名称。
basedir: 项目引用的根路径。
ant.home: Ant工具的根目录位置。
ant.file: 构件文件的绝对路径。
ant.version: ant的版本信息。
ant.java.version: ant检测到的JVM版本。
ant.project.name: 当前执行的项目名称及信息。
java.version: Java的版本信息。
java.home: Java的根目录位置。
java.class.path: Java类库的文件的位置。
line.separator: 换行符.
(5)编译的时候如果在windows下面使用命令行来运行ant的话,工程使用UTF-8,编译会有编码错误。需要设定编译的编码