ant 常用脚本

上一篇 / 下一篇  2014-03-11 17:05:41 / 个人分类:scm

xml version="1.0" encoding="utf-8"?>
<!--
================================================
 -->
<!--
后台服务程序
 -->
<!--
 -->
<!--
================================================
 -->
-<projectname="LuckyAppSrv"basedir="."default="main">
 <description>com.llt.parkpay.user</description>
<!--
全局变量定义
 -->
 <propertyname="src.dir"value="src"/>
<!--
源代码目录
 -->
 <propertyname="build.dir"value="build"/>
<!--
编译目标文件目录
 -->
 <propertyname="build.lib.dir"value="lib"/>
<!--
编译目标文件目录
 -->
 <propertyname="lib.dir"value="lib"/>
<!--
第三方工具类文件
 -->
 <propertyname="res.dir"value="res_test"/>
<!--
资源文件目录
 -->
 <propertyname="classes.dir"value="${build.dir}/bin"/>
<!--
编译生成Class文件目录
 -->
 <propertyname="jar.dir"value="${build.dir}"/>
<!--
打包生成jar文件目录
 -->
 <propertyname="version"value="0.1"/>
<!--
指定程序的版本号,该值会添加到生成jar文件的后面。
 -->
 <propertyname="main-class"value="com.nnk.bazi.kyjl.app.start.Start"/>
<!--
程序入口对象
 -->
 <propertyname="encoding"value="UTF-8"/>
<!--
编译目标的编码
 -->
 <propertyname="antlib.dir"value="ant-lib"/>
<!--
主程序文件名
 -->
 <propertyname="app.name"value="${ant.project.name}-${version}.jar"/>
<!--
程序运行路径
 -->
 <propertyname="app.dir"value="/usr/local/007ka/baizi/Kaiyun/LuckyAppSrv"/>
<!--
程序关闭重启脚本路径
 -->
 <propertyname="sh.dir"value="/usr/local/007ka/sh"/>
-<targetname="main"depends="clean, preapare, compile, copylib, jar, resources,restart_app"description="控制编译执行流程">
 <echo>, resources, cleanup, update, restart_app编译完成^_^</echo>
 <echo>目标jar文件:${jar.dir}/${ant.project.name}-${version}.jar</echo>
 </target>
<!--
- - - - - - - - - - - - -
 -->
<!--
target: clean
 -->
<!--
- - - - - - - - - - - - -
 -->
-<targetname="clean"description="删除旧的二进制代码">
 <echo>清除旧的二进制文件</echo>
 <deletedir="${build.dir}"/>
 </target>
<!--
- - - - - - - - - - - - -
 -->
<!--
target: cleanup
 -->
<!--
- - - - - - - - - - - - -
 -->
-<targetname="cleanup"description="清除编译的的二进制代码">
 <echo>清除编译的的二进制代码</echo>
 <deletedir="${classes.dir}"/>
 </target>
-<targetname="preapare"depends="clean"description="准备文件目录">
 <echo>为之后操作创建文件目录</echo>
 <mkdirdir="${classes.dir}"description="存放字节码文件"/>
 <mkdirdir="${jar.dir}"description="存放打包之后的jar文件"/>
 </target>
-<targetname="compile"depends="preapare"description="编译java文件为字节码class">
 <echo>编译</echo>
-<javacsrcdir="${src.dir}"destdir="${classes.dir}"includeantruntime="false"source="1.6"target="1.6"debug="true">
 <compilerargline="-encoding ${encoding}"/>
-<compilerclasspath>
 <pathelementpath="${antlib.dir}/ecj.jar"/>
 </compilerclasspath>
-<classpath>
-<filesetdir="${lib.dir}">
 <includename="*.jar"/>
 </fileset>
 </classpath>
 </javac>
 </target>
-<targetname="copylib"depends="compile"description="复制第三方jar文件">
 <echo>复制第三方jar文件</echo>
-<copytodir="${build.dir}/${build.lib.dir}">
-<filesetdir="${lib.dir}">
 <includename="**/*"/>
 </fileset>
 </copy>
 </target>
-<pathconvertproperty="project.libs"pathsep=""description="定义程序的第三方jar文件路径">
-<mapper>
-<chainedmapper>
<!--
移除绝对路径
 -->
 <flattenmapper/>
<!--
添加lib前缀
 -->
 <globmapperfrom="*"to="${build.lib.dir}/*"/>
 </chainedmapper>
 </mapper>
-<path>
-<filesetdir="${lib.dir}">
 <includename="**/*.jar"/>
 </fileset>
 </path>
 </pathconvert>
-<targetname="jar"description="将字节码文件打包成jar文件">
 <echo>打包jar文件</echo>
-<jardestfile="${jar.dir}/${app.name}"basedir="${classes.dir}">
-<manifest>
 <attributename="Main-Class"value="${main-class}"/>
 <attributename="Class-Path"value=". ${project.libs}"/>
 </manifest>
 </jar>
 </target>
-<targetname="resources"depends="jar"description="配置运行需要的配置信息">
 <echo>配置运行环境</echo>
 <mkdirdir="${app.dir}"description="程序运行路径"/>
-<copytodir="${app.dir}"overwrite="false">
-<filesetdir="${res.dir}">
 <includename="**/*"/>
 </fileset>
 </copy>
 <echo>复制第三方jar文件</echo>
-<copytodir="${app.dir}/${build.lib.dir}">
-<filesetdir="${lib.dir}">
 <includename="**/*"/>
 </fileset>
 </copy>
 <echo>复制主程序</echo>
 <copytodir="${app.dir}"file="${jar.dir}/${app.name}"/>
<!--
antcall target="restart_app"></antcall
 -->
 </target>
-<targetname="run"depends="resources">
 <antcalltarget="shutdown_app"/>
 <echo>重启程序</echo>
 <javaclasspath="."jar="${app.dir}/${app.name}"dir="${app.dir}"spawn="false"fork="true"/>
 </target>
-<targetname="shutdown_app"description="关闭程序">
-<execexecutable="${sh.dir}/shutdown.sh">
 <argvalue="${ant.project.name}"/>
 </exec>
 </target>
-<targetname="start_app"description="启动程序">
-<execexecutable="${sh.dir}/startup.sh">
 <argvalue="${app.dir}"/>
 <argvalue="${app.name}"/>
 </exec>
 </target>
-<targetname="restart_app"depends="resources"description="重启程序">
-<execexecutable="${sh.dir}/restart.sh"failonerror="true">
 <argvalue="${ant.project.name}"/>
 <argvalue="${app.dir}"/>
 <argvalue="${app.name}"/>
 </exec>
 </target>
<!--
target name="clearUp" description="清理生成的临时文件">
		<echo>清理构建中产生的临时文件</echo>
		<delete dir="${classes.dir}" />
	</target>

	<target name="update" depends="jar" description="上传">
		<echo message="将jar上传服务器" />
		<scp file="${jar.dir}/${ant.project.name}-${version}.jar" todir="${user_253}:${password_253}@${address_253}"    
			            trust="true" verbose="true"/>
		<echo message="上传完毕" />
	</target>
	<target name="restart_app" depends="update" description="关闭重启应用程序">
		<sshexec host="${host_253}" username="${user_253}" password="${password_253}" trust="true" command="sh/restart.sh ${ant.project.name} ${dir_253} ${app.name}" />
	</target>

	<target name="mk" >

		<sshexec host="" username="" command="" failonerror="true" />
		<exec dir="/ci/opt/cruisecontrol-bin-2.7.3/projects/maketest" executable="make" s="Linux"  failonerror="true"/>
	</target
 -->
 </project>

TAG:

 

评分:0

我来说两句

Open Toolbar