码迷,mamicode.com
首页 > 其他好文 > 详细

ant的build.xml备份

时间:2018-01-13 14:16:01      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:copy   map   value   monit   rom   fork   odex   style   rate   

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

<project default="rerun" name="codex-game">

<!-- project  property -->

<property name="lib.dir" value="../third-libs" />

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

 

<!--

<property name="core.moniter.dir" value="../dawn-core/moniter" />

<property name="core.src.dir" value="../dawn-core/src" />

<property name="dbs.src.dir" value="../dawn-dbs/src" />

<property name="dbs.test.dir" value="../dawn-dbs/test" />

<property name="logserver.src.dir" value="../logserver/src" />

-->

 

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

<property name="classes.dir" value="deploy/classes" />

 

<property name="jarname" value="codex-game.jar" />

<property name="mainclass" value="com.mop.game.gameserver.GameServer" />

 

<property name="core.jar" value="codex-core/deploy/codex-core.jar" />

<property name="dbs.jar" value="codex-db/deploy/codex-db.jar" />

<property name="battle.jar" value="codex-battle/deploy/codex-battle.jar" />

<property name="log.jar" value="logserver/deploy/logserver.jar" />

 

<!-- third jar path -->

<path id="lib-classpath">

<fileset dir="${lib.dir}">

<include name="**/*.jar" />

</fileset>

<fileset dir="../">

<include name="${core.jar}" />

</fileset>

<fileset dir="../">

<include name="${dbs.jar}" />

</fileset>

<fileset dir="../">

<include name="${battle.jar}" />

</fileset>

<fileset dir="../">

<include name="${log.jar}" />

</fileset>

</path>

 

 

<!-- 1. init, eg.create path -->

<target name="init">

<mkdir dir="${deploy.dir}" />

<mkdir dir="${classes.dir}" />

</target>

 

 

<!-- 2. compile -->

<target name="compile" depends="init">

<javac destdir="${classes.dir}" includeantruntime="on">

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

<compilerarg line="-encoding UTF-8" />

<classpath refid="lib-classpath" />

</javac>

</target>

 

 

<!-- 3. build jar -->

<target name="build" depends="compile">

<copy todir="${deploy.dir}/lib">

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

<file name="../${core.jar}" />

<file name="../${dbs.jar}" />

<file name="../${battle.jar}" />

<file name="../${log.jar}" />

</copy>

 

<copy todir="${deploy.dir}">

<fileset dir="../codex-db/resource" />

</copy>

 

<copy todir="${deploy.dir}">

<fileset dir="resource" />

</copy>

 

<!--Create a property containing all .jar files, prefix lib/, and seperated with a space-->

<pathconvert property="mf.classpath" pathsep=" ">

<mapper>

<chainedmapper>

<!-- jar包文件只留文件名,去掉目录信息 -->

<flattenmapper />

<!-- add lib/ prefix -->

<globmapper from="*" to="lib/*" />

</chainedmapper>

</mapper>

<path refid="lib-classpath" />

</pathconvert>

 

<!-- jar文件的输出路径 -->

<jar destfile="${deploy.dir}/${jarname}" basedir="${classes.dir}">

<manifest>

<attribute name="Main-class" value="${mainclass}" />

<attribute name="Class-Path" value="${mf.classpath}" />

</manifest>

</jar>

<delete dir="${classes.dir}" />

</target>

 

<!-- run -->

<target name="run" depends="build">

<java classname="${mainclass}" classpath="${deploy.dir}/${jarname}" fork="true" failonerror="true">

<classpath>

<pathelement path="${deploy.dir}" />

</classpath>

</java>

</target>

 

 

<target name="clean">

<delete file="${deploy.dir}/${jarname}" />

<delete dir="${deploy.dir}/lib" />

<delete dir="${classes.dir}" />

</target>

 

<target name="rebuild">

<ant target="clean" />

<ant target="build" />

</target>

 

<target name="rerun">

<!--ant target="clean" /-->

<ant target="run" />

</target>

 

</project>

 

 

 

 

 

 

 

 

 

 

 

 

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

<project default="rebuild" name="codex-core">

<!-- project  property -->

<property name="lib.dir" value="../third-libs" />

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

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

 

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

<property name="classes.dir" value="deploy/classes" />

 

<property name="jarname" value="codex-core.jar" />

 

<!-- third jar path -->

<path id="lib-classpath">

<fileset dir="${lib.dir}">

<include name="**/*.jar" />

</fileset>

</path>

 

 

<!-- 1. init, eg.create path -->

<target name="init">

<mkdir dir="${deploy.dir}" />

<mkdir dir="${classes.dir}" />

</target>

 

 

<!-- 2. compile -->

<target name="compile" depends="init">

<javac destdir="${classes.dir}" includeantruntime="on" debug="on" optimize="true">

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

<src path="${moniter.dir}" />

<compilerarg line="-encoding UTF-8" />

<classpath refid="lib-classpath" />

</javac>

</target>

 

 

<!-- 3. build jar -->

<target name="build" depends="compile">

<copy todir="${deploy.dir}/lib">

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

</copy>

 

<!--Create a property containing all .jar files, prefix lib/, and seperated with a space-->

<pathconvert property="mf.classpath" pathsep=" ">

<mapper>

<chainedmapper>

<!-- jar包文件只留文件名,去掉目录信息 -->

<flattenmapper />

<!-- add lib/ prefix -->

<globmapper from="*" to="lib/*" />

</chainedmapper>

</mapper>

<path refid="lib-classpath" />

</pathconvert>

 

<!-- jar file output -->

<jar destfile="${deploy.dir}/${jarname}" basedir="${classes.dir}">

<manifest>

<attribute name="Class-Path" value="${mf.classpath}" />

</manifest>

</jar>

<delete dir="${deploy.dir}/lib" />

<delete dir="${classes.dir}" />

</target>

 

 

<target name="clean">

<delete file="${deploy.dir}/${jarname}" />

<delete dir="${deploy.dir}/lib" />

<delete dir="${classes.dir}" />

</target>

 

 

<target name="rebuild">

<ant target="clean" />

<ant target="build" />

</target>

 

 

</project>

ant的build.xml备份

标签:copy   map   value   monit   rom   fork   odex   style   rate   

原文地址:https://www.cnblogs.com/xingchong/p/8278741.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!