lvjian700
5/19/2013 - 9:31 AM

Compile Java Project include jar & doc

Compile Java Project include jar & doc

<?xml version="1.0" encoding="utf-8" ?>
<project name="uploadfile" default="compile" basedir=".">
  <property name="src.dir" value="src/java" />
	<property name="test.dir" value="src/test" />
	<property name="res.dir" value="src/resources" />

	<property name="bin.dir" value="bin" />
	<property name="lib.dir" value="libs" />
	<property name="doc.dir" value="doc" />
	<property name="classes.dir" value="${bin.dir}/classes" />
	<property name="version" value="0.1.0" />


	<!-- 定义classpath -->
	<path id="classpath">
		<fileset dir="${lib.dir}" includes="**/*.jar" />
	</path>

	<!-- 创建构建目录,用于存放构建生成的文件 -->
	<target name="init">
		<mkdir dir="${bin.dir}"/>
	</target>

	<!-- 编译 -->
	<target name="compile" depends="init">
		<mkdir dir="${classes.dir}"/>
		<javac srcdir="${src.dir}" destdir="${classes.dir}" 
			classpathref="classpath">
			<compilerarg line="-encoding UTF-8"/>
		</javac>

		<!-- copy properties file to classpath -->
		<copy todir="${classes.dir}">
			<fileset dir="${res.dir}" excludes="**.*.jar" />
		</copy>
	</target>

	<target name="clean">
		<delete dir="${bin.dir}"/>
		<delete dir="${classes.dir}"/>
	</target>


	<target name="jar" depends="compile">
		<delete dir="${bin.dir}/jar"/>
		<mkdir dir="${bin.dir}/jar"/>
		<jar destfile="${bin.dir}/jar/push4j-client.${version}.jar">
			<fileset dir="${classes.dir}">
				<include name="**/*.class"/>
				<exclude name="**/*.properties"/>
			</fileset>
			<zipgroupfileset dir="${lib.dir}" includes="socketio.jar" />
			<manifest></manifest>
		</jar>
	</target>

	<target name="doc" depends="compile">
		<javadoc sourcepath="${src.dir}" destdir="${doc.dir}" encoding="UTF-8" docencoding="UTF-8">
			<excludepackage name="com.dayang.pusher4j.sample"/>
			<classpath refid="classpath"></classpath>
		</javadoc>
	</target>
</project>