<?xml version="1.0" encoding="UTF-8"?>
<project default="deploy-all" name="172.16.1.162" basedir="../.">
<description>
自动编译打包脚本
</description>
<echo>Building ...</echo>
<echo>basedir: ${basedir}</echo>
<!--定义相关编译变量-->
<property name="exclude-svn" value="**/*.svn/*.*,servlet-api.jar" />
<property name="exclude-local" value="*.propertieslocal,terracotta-toolkit-1.6-runtime-5.5.0.jar" />
<property name="java-version" value="1.8" />
<property name="is-debug" value="on" />
<property name="app-version" value="0.1" />
<property name="myhost" value="127.0.0.1" />
<property name="host" value="192.168.71.128" />
<property name="user" value="root" />
<property name="password" value="123456" />
<property name="port" value="22" />
<property name="ftpserverdir" value="/game/server" />
<property name="gameserverdir" value="${host}:${ftpserverdir}/app/gameserver" />
<!--输入变量定义-->
<property name="gameserver" value="${basedir}/HelloAnt" />
<!--定义最终文件输出路径-->
<property name="app-out" value="${basedir}/deploy/app" />
<property name="gameserver-out" value="${app-out}/gameserver" />
<!-- 清除已生成的旧版本文件 -->
<target name="clean">
<delete dir="${app-out}" />
</target>
<!-- 创建部署文件所需路径 -->
<target name="init" depends="clean">
<mkdir dir="${app-out}" />
<!-- GameServer -->
<mkdir dir="${gameserver-out}" />
<mkdir dir="${gameserver-out}/lib" />
</target>
<!-- 编译项目 -->
<target name="compile-gameserver" depends="init">
<javac encoding="utf-8" includeAntRuntime="false" srcdir="${gameserver}/src" destdir="${gameserver}/bin" source="${java-version}" target="${java-version}" debug="${is-debug}">
<classpath refid="lib-path" />
</javac>
</target>
<!-- 打包GameServer -->
<target name="deploy-gameserver" depends="compile-gameserver">
<jar basedir="${gameserver}/bin" destfile="${gameserver-out}/gameserver_${app-version}.jar">
<manifest>
<attribute name="Main-Class" value="com.road.game.TestAnt" />
</manifest>
</jar>
</target>
<target name="deploy-all" depends="clean, deploy-gameserver">
</target>
<target name="upload-server" depends="deploy-all">
<echo>==========================start upload==========================</echo>
<!-- 上传GameServer到 FTP 服务器-->
<scp port="${port}" todir="${user}:${password}@${gameserverdir}" trust="true" verbose="true">
<fileset dir="${gameserver-out}">
</fileset>
</scp>
<echo>==========================end upload=====================================</echo>
</target>
</project>
备注一份简单的ant脚本
最新推荐文章于 2018-03-16 14:09:13 发布