<?xml version="1.0" encoding="UTF-8"?>

<project name="projectName" default="zip" basedir=".">

<target name="setvar"> 变量的设定

<property name="build" value="build"/>

<property name="buildClass" value="${build}/classes"/>

<property name="buildDist" value="${build}/dist"/>

<property name="buildDistLib" value="${buildDist}/lib"/>

<property name="module" value="testModule"/>

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

<property name="lastvalidatetime" value="lastvalidatetime"/>

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

<path id="my-class-path"> //设置path变量

<fileset dir="${lib}" includes="*.jar"/>

</path>

<tstamp> //设置运行的时间戳变量

<format property="today" pattern="MM/dd/yyyy hh:mm aa" locale="en"/>

<format property="time" pattern="yyyyMMdd_HHmmss" locale="en"/>

<format property="date" pattern="yyyyMMdd" locale="en"/>

</tstamp>

<property name="timestamp" value="${time}"/>

<property file="build.properties"/>//引入property文件,之后可以用里面的key获取value,如:build.version=4.0

<property name="build.name" value="${module}_v${build.version}_${date}"/>

<property name="versionPath" value="/version"/>

</target>

<target name="clean" depends="setvar">

<delete dir="${build}"/>//删除build文件夹

<mkdir dir="${build}"/>//创建 build文件夹

<mkdir dir="${buildClass}"/>//创建build/classes文件夹

<mkdir dir="${buildDist}"/>//创建build/dist文件夹

<mkdir dir="${buildDistLib}"/>创建build/dist/lib文件夹

</target>

<target name="compile-classes" depends="clean"> //编译,依赖clean

    //http://ant.apache.org/manual/Tasks/javac.html

    //必须要有srcdir,除非有内嵌的<src>

<javac debug="on" deprecation="on" includeantruntime="false" source="1.6" target="1.6" destdir="${buildClass}"> //编译到build/classes

<classpath>//The classpath to use.需要依赖哪些包时

<path refid="my-class-path"/>

</classpath>

<src path="${src}"/>

</javac>

</target>

<target name="jar" depends="compile-classes">//打包jar

<jar jarfile="${build}/${module}.jar" basedir="${buildClass}"> //将编译出build/classes的class打包为build\testModule.jar

<manifest/>

</jar>

</target>

<target name="work" depends="jar">

<copy todir="${buildDistLib}">//复制文件到build/dist/lib

<fileset dir="${lib}" includes="*.jar"/> //复制文件${lib}下所有jar文件到${buildDistLib}

<fileset dir="${build}" includes="${module}.jar"/> //复制文件${build}下testModule.jar文件到${buildDistLib}

</copy>

<copy todir="${buildDist}">

<fileset dir="./" includes="*.bat,lastsynctime/*,deviceType/*,"/>//复制当前目录去.bat...到${buildDist}

</copy>

<copy todir="${buildDist}/config.default">//复制config目录去${buildDist}/config.default目录

<fileset dir="config" includes="**"/>

</copy>

<copy todir="${buildDist}" file="README.md" />

<copy todir="${buildDist}" file="init.sql" />

<copy todir="${buildDist}" file="curlTool.rar" />

<delete dir="${buildClass}"/>

<delete file="${build}/${module}.jar"/>

<property name="versionFolder" value="${buildDist}/${versionPath}"/>

<delete dir="${versionFolder}"/>

<mkdir dir="${versionFolder}"/>//创建${buildDist}/${versionPath}文件夹

<property name="fileName" value="${versionFolder}/${build.name}.txt"/>

<echo message="** Build Information ** ${line.separator}" file="${fileName}"/> //将显示信息输入到文件${fileName}换行

<echo message="Version: ${build.version}${line.separator}" file="${fileName}" append="true"/>//将显示信息输入追加到文件${fileName}换行

<echo message="Build Time: ${timestamp}${line.separator}" file="${fileName}" append="true"/>

<echo message="Java Version: ${java.runtime.version}${line.separator}" file="${fileName}" append="true"/>

<!-- MD5 info-->

<echo message="--- md5 info ---${line.separator}" file="${fileName}" append="true"/>

<checksum file="${buildDist}/${lib}/test1.jar" property="test1MD5"/> //check MD5 test1.jar 到test1MD5

<echo message="test1.jar:${test1MD5}${line.separator}" file="${fileName}" append="true"/>

<checksum file="${buildDist}/${lib}/${module}.jar" property="test2MD5"/>

<echo message="${module}.jar:${test2MD5}${line.separator}" file="${fileName}" append="true"/>

</target>

<target name="zip" depends="work">

<zip destfile="${build}/${module}.zip" basedir="${buildDist}"/> //将${buildDist}打包为${build}/${module}.zip

</target>

</project>

Ant的使用(一)的更多相关文章

  1. Jenkins 安装的HTML Publisher Plugin 插件无法展示ant生成的JunitReport报告

    最近在做基于jenkins ant  junit 的测试持续集成,单独ant junit生成的junitreport报告打开正常,使用Jenkins的HTML Publisher Plugin 插件无 ...

  2. React中使用Ant Table组件

    一.Ant Design of React http://ant.design/docs/react/introduce 二.建立webpack工程 webpack+react demo下载 项目的启 ...

  3. [Ant]Ant简易教程

    前言 Apache Ant,是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发.由Apache软件基金会所提供. Ant是纯Java语言编写的,所以具有 ...

  4. jenkins / ant / jmeter 持续集成接口自动化

    1. 将 jmeter 脚本放在/var/lib/jenkins/workspace/Jmeter_auto/jmxpath路径下 2. 点击http://jk.facebank.net.cn/job ...

  5. Maven与Ant比较

    Maven与Ant比较 0 « 上一篇:Jenkins学习三:介绍一些Jenkins的常用功能» 下一篇:Jenkins学习四:Jenkins 邮件配置 posted @ 2015-03-25 16: ...

  6. 一.Jmeter+Ant+Jenkins搭建持续集成接口性能自动化测试

    微创新作品信息 1)微创新作品描述 A.为什么诞生: 1. 接口测试是测试系统组件间接口的一种测试.接口测试主要用于检测外部系统与系统之间以及内部各个子系统之间的交互点.测试的重点是要检查数据的交换, ...

  7. Eclipce结合Ant进行编译、打包、传输、运行

    注意: 用Ant构建时,build path只能是单级的,如默认的src,如果是类似basePath/jsr253这样的话,运行Ant build时会报错,说找不到jsr253. (此文讲述的是以an ...

  8. ant 使用指南

    一.概述 ant 是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发.在实际软件开发中,有很多地方可以用到ant. 开发环境: System:Windo ...

  9. 在Eclipse中集成Ant配置

    提要:本文将向你展示如何使用Eclipse设置为Ant所用的属性值和环境变量,并简要分析如何配置Ant编辑器以便从Eclipse内部操作Ant文件. 一. 修改Ant Classpath 在使用一个可 ...

  10. windows+ant+git+tomcat中ant直接获取git项目部署注意点

    最近项目搬迁到公司的"GitHub"上面原来的SVN的ant发布脚本要改下,于是百度ant获取git的方法太少了,windows平台上更是没有所以搞了两天,今天终于有点成果分享给大 ...

随机推荐

  1. Scala学习——函数

    一.函数的定义(def) object FunctionApp { //定义函数:方法体内最后一行为返回值,不需要使用return def add(a:Int,b:Int):Int={ a + b } ...

  2. linux U盘安装系统工具usb-creator-gtk

    linux平台下U盘安装linux系统的工具.它是ubuntu自带的工具,将建时将覆盖U盘中的所有内容.

  3. nacos Connection refused (Connection refused)

    记录一次"异常bug",具体信息如下.主要是记录一下处理过程,可能口水话比较多,如果想看结果,直接往后拉即可. 最后一行 起初,运维同事找到我,跟我说程序出问题了,系统升级,一直连 ...

  4. 【贪心+排序】排队接水 luogu-1223

    题目描述 有n个人在一个水龙头前排队接水,假如每个人接水的时间为Ti,请编程找出这n个人排队的一种顺序,使得n个人的平均等待时间最小. 分析 注意要开longlong AC代码 #include &l ...

  5. tomcat内置jdk(tomcat集成jdk)(windows环境)

    tomcat内置jdk,步骤: 1.在一个已经安装了jdk或者jre的机器上,拷贝一个jre到tomcat根目录下. 2.编辑tomcat/bin文件夹下的catalina.bat文件,在文件开头加上 ...

  6. ODOO14笔记---系统升级崩溃后进不去系统解决办法

    一.通过pycharm升级模块:  2.对于已安装odoo模块,升级报错系统崩溃的解决办法:---执行以下SQL     update ir_module_module set state ='ins ...

  7. CentOS7安装桌面环境以及中文语言支持

    CentOS7 操作系统 http://public-yum.oracle.com/oracle-linux-isos.html ================================= 1 ...

  8. 解决:CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

    log4j给出的异常信息有下面几句: Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC C ...

  9. Android系统编程入门系列之加载服务Service

    之前几篇文章简单梳理了在Android系统的四大组件之一,最主要的界面Activity中,使应用程序与用户进行交互响应的相关知识点,那对于应用程序中不需要与用户交互的逻辑,又要用到哪些内容呢?本文开始 ...

  10. HCNA Routing&Switching之VLAN间路由

    前文我们了解了二层交换技术vlan相关话题,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15091491.html:今天我们来聊一聊不同VLAN间通信相关话题 ...