ant是一个脚本构建工具,可能就是持续集成里面所需要的构建工具。

如果使用eclipse,里面会自带有ant工具,不需要再安装了,创建一个build.xml(或者其他的名字都可以),使用ant来运行就可以了

如果使用的命令行来运行ant,需要安装的步骤如下:

(1)下载ant,解压,无需安装过程。

(2)将ant的bin目录加入到系统的环境变量path中。

(3)运行ant,可以查看是否加成功了。

(4)在cmd中,将目录切换到工程所在的build.xml目录下,运行ant(这里默认为build.xml文件,还可以自己制定需要的文件)

关于build.xml文件的目录结构

<project name="**">

<property name="src" value="test" />

<path id="classpath1.path">
<fileset dir="${lib.dir}">

<property name="dest" value="classes" />

<property name="lib.dir" value="lib"/>

<include name="*.jar" />

</fileset>

<pathelement location="${src}" />

<pathelement location="${dest}"/>
</path>

<!-- 定义一些初始化的操作 !-->

<target name="init">
    <delete verbose="true" includeemptydirs="true">
    <fileset dir="${dest}">
        <include name="**/*"/>
    </fileset>
</delete>
<mkdir dir="${dest}" />
</target>

<!--编译 !-->

<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${dest}" classpathref="classpath1.path"/>
<echo message="${TIME}" />
</target>

<!--接下来有一些你需要做的事情,比如打包部署,或者运行一个程序等 !-->

...

</project>

一些需要记录的东西:

(1)运行一个java程序的定义:

<target name="sendmail" depends="compile">
   <java classname="com.sogou.maps.testApi.Integration" classpathref="classpath1.path">
       <classpath path="${dest}"></classpath>
       <arg value="${basedir}/${TIME}/emailable-report.html"></arg>
   </java>
</target>

如果引用了第三方的包,那么需要在classpathref中定义,否则会提示错误信息。

(2)定义一个时间戳

<tstamp> 
         <format property="TIME" pattern="yyyyMMdd-hhmm" locale="en,UK"/> 
    </tstamp>

只要定义了这个,就定义了三个参数: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,编译会有编码错误。需要设定编译的编码

<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${dest}" classpathref="classpath1.path">
<compilerarg line="-encoding UTF-8"></compilerarg>
</javac>
<echo message="${TIME}" />
</target>

ant使用备忘的更多相关文章

  1. GIS部分理论知识备忘随笔

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.高斯克吕格投影带换算 某坐标的经度为112度,其投影的6度带和3度带 ...

  2. python序列,字典备忘

    初识python备忘: 序列:列表,字符串,元组len(d),d[id],del d[id],data in d函数:cmp(x,y),len(seq),list(seq)根据字符串创建列表,max( ...

  3. Vi命令备忘

    备忘 Ctrl+u:向文件首翻半屏: Ctrl+d:向文件尾翻半屏: Ctrl+f:向文件尾翻一屏: Ctrl+b:向文件首翻一屏: Esc:从编辑模式切换到命令模式: ZZ:命令模式下保存当前文件所 ...

  4. ExtJs4常用配置方法备忘

    viewport布局常用属性 new Ext.Viewport({ layout: "border", renderTo: Ext.getBody(), defaults: { b ...

  5. [备忘] Automatically reset Windows Update components

    这两天遇到Windows 10的更新问题,官方有一个小工具,可以用来修复Windows Update的问题,备忘如下 https://support.microsoft.com/en-us/kb/97 ...

  6. ECMAScript 5(ES5)中bind方法简介备忘

    一直以来对和this有关的东西模糊不清,譬如call.apply等等.这次看到一个和bind有关的笔试题,故记此文以备忘. bind和call以及apply一样,都是可以改变上下文的this指向的.不 ...

  7. MFC通过txt查找文件并进行复制-备忘

    MFC基于对话框的Demo txt中每行一个23位的卡号. 文件夹中包含以卡号命名的图像文件.(fpt或者bmp文件) 要求遍历文件夹,找到txt中卡号所对应的图像文件,并复制出来. VC6.0写的. ...

  8. php 相关模块备忘

    在安装php的时候,不管是编译安装: ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc -- ...

  9. 『备忘』HttpWebRequest 在 POST 提交时, 标头(Headers)丢失原因

    近来研究 HttpWebRequest —— 辅助类完成时,POST JSON数据 总会 丢失标头(Headers). HttpWebRequest POST JSON数据,分如下几步: > 将 ...

随机推荐

  1. 深入理解ASP.NET MVC(1)

    系列目录 ASP.NET MVC请求的服务过程 下图是书中的截图,表述了一次通常的ASP.NET MVC请求的服务过程: 从图中可以初步看出一个HttpRequest是如何被ASP.NET和ASP.N ...

  2. CentOS启动网络提示connect: Network is unreachable(配置静态路由)

    ls /etc/sysconfig/network-script/ifcfg-eth0 一.看是否在上述目录下存在ifcfg-eth0 这个文件,若存在则按下面的步骤操作: 1.手工配置ip看能不能配 ...

  3. 论战大数据----胖子哥的PK之旅(一)

    胖子哥(1106110976) 9:35:36 http://www.cnblogs.com/hadoopdev/p/3531963.htmlnosqlt数据库-肖(380594863) 9:38:0 ...

  4. 【Spring学习笔记-MVC-1.3】消息转换器HttpMessageConverter

    作者:ssslinppp       参考链接: SpringMVC源码剖析(五)-消息转换器HttpMessageConverter: http://my.oschina.net/lichhao/b ...

  5. 【XMLHttpRequest】获取XMLHttpRequest

    // 获取http请求 function getXMLHttpRequest() { req = false; //本地XMLHttpRequest对象 if (window.XMLHttpReque ...

  6. springMVC学习(12)-使用拦截器

    一.拦截器配置和测试: 1)定义两个拦截器,(要实现HandlerInterceptor接口) HandlerInterceptor1: package com.cy.interceptor; imp ...

  7. canvas基础一

    使用HTML5中<canvas>元素可以在页面中设定一个区域,然后通过JavaScript动态地在这个区域中绘制图形,要在这块画布(canvas)上绘图,需要取得绘图上下文,而取得绘图上下 ...

  8. Java-Web中访问某个指定工程中的文件,报错后发现访问的文件是另一个工程里面的文件

    问题: 浏览器向我的bingou项目中的UserDaoImpl.java发送请求, myeclipse报错:空指针异常 点击报错行之后,错误给定位到了另一个项目中的的一个文件 解决: 原因是文件名错误 ...

  9. Bootstrap table的一些简单使用总结

    在GitHub上Bootstrap-table的源码地址是:https://github.com/wenzhixin/bootstrap-table Bootstrap-table的文档地址:http ...

  10. Opencv 入门学习1

    1. 读取图像并显示 import cv2 img = cv2.imread('../samples/c/lena.jpg') cv2.nameWindow("Image") #可 ...