<?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>

05-24 06:14