这里使用1.9.7版ant
地址:http://ant.apache.org/bindownload.cgi
#配置环境变量
#新建一个环境变量AHT_HOME
#将ANT_HOME添加到Path中去
#在cmd 中输入 ant -version
Apache Ant(TM) version 1.9.7 compiled on April 9 2016
达成的功能概要为
1.编译文件
2.编译后的文件放到一个临时目录
3.根据选择的配置来加载不同的properties文件,并改名{ db55.properties 改为 db.properties }
4.打包war
5.ssh链接,上传
6.执行shell脚本
项目中新建build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="myAnt" basedir="." default="ini">
<!--加载基础配置文件-->
<import file="${basedir}/buildConfig.xml" />
<!--加载服务器配置文件-->
<import file="${basedir}/buildServerConfig.xml" />
<!--【操作列表】-->
<!--配置选择器-->
<target name="ini">
<echo>请输入要加载的配置服务器标识</echo>
<input addproperty="select" message="请输入要加载的配置服务器标识" />
<!--192.168.1.55-->
<condition property="${config55}">
<equals arg1="${config55}" arg2="${select}" />
</condition>
<antcall target="server55" />
<!--192.168.1.66-->
<condition property="${config66}">
<equals arg1="${config66}" arg2="${select}" />
</condition>
<antcall target="server66" />
</target>
<!--编译java文件-->
<target name="compile">
<echo>----开始编译Java文件</echo>
<echo>清理${pname} -> classes目录</ech