- build.xml
<project basedir="." default="jar" name="core">
<target name="init">
<!-- property settings -->
<property file="build.properties" />
<echo message="----------- ${Name} ${version} [${year}] ------------" />
<property name="debug" value="off" />
<property name="optimize" value="on" />
<property name="deprecation" value="on" />
<!--<property name="mycedatasycn.location" value="D:/project/myce/mycedatasycn" />-->
<!-- java源文件路径 -->
<property name="src.dir" value="${basedir}/src" />
<!-- jar包路径 -->
<property name="lib.dir" value="${basedir}/lib" />
<!-- 准备源文件路径 -->
<property name="build.src" value="${basedir}/build/classes" />
<!-- 编译源文件路径 -->
<property name="build.dest" value="${basedir}/build/bin" />
<!-- 准备javadoc文件路径 -->
<property name="build.javadocs" value="${basedir}/AntBuild/doc" />
<!-- 打包jar文件路径 -->
<property name="jar.dest" value="${basedir}/build/lib" />
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<!--<pathelement location="lib/"/>-->
</path>
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${Name} Build file" />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message=" available targets are:" />
<echo message="" />
<echo message=" jar --> generates the ${name}.jar file" />
<echo message=" build --> compiles the source code" />
<echo message=" javadoc --> generates the API documentation" />
<echo message=" clean --> cleans up the directory" />
<echo message="" />
<echo message=" Please rename build.properties.default to build.properties" />
<echo message=" and edit build.properties to specify JSDK 2.3 classpath." />
<echo message="" />
<echo message=" See the comments inside the build.xml file for more details." />
<echo message="-------------------------------------------------------------" />
<echo message="" />
<echo message="" />
</target>
<!-- =================================================================== -->
<!-- 准备源文件-->
<!-- =================================================================== -->
<target name="prepare-src" depends="init">
<!-- create directories -->
<mkdir dir="${basedir}/build" />
<mkdir dir="${build.src}" />
<mkdir dir="${build.dest}" />
<mkdir dir="${jar.dest}" />
<!-- copy src files -->
<copy todir="${build.src}">
<fileset dir="${src.dir}/main/java" />
<fileset dir="${src.dir}/main/resources" />
</copy>
</target>
<!-- =================================================================== -->
<!-- 编译源文件-->
<!-- =================================================================== -->
<target name="build" depends="clean,prepare-src">
<javac srcdir="${build.src}" destdir="${build.dest}" debug="${debug}" optimize="${optimize}">
<classpath refid="classpath" />
<compilerarg line="-encoding UTF-8 " />
</javac>
<copy todir="${build.dest}">
<fileset dir="${build.src}">
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<target name="jar" depends="build">
<jar destfile="${jar.dest}/${product.name}-${product.version}.jar" basedir="${build.dest}">
</jar>
</target>
<!-- =================================================================== -->
<!-- 产生javadoc api 文档-->
<!-- =================================================================== -->
<target name="javadoc" depends="build">
<mkdir dir="${build.javadocs}" />
<javadoc packagenames="${packages}" sourcepath="${build.src}" destdir="${build.javadocs}" author="true" version="true" use="true" splitindex="true" windowtitle="${Name} API" doctitle="${Name}">
<classpath refid="classpath" />
</javadoc>
</target>
<!-- =================================================================== -->
<!-- 清除临时文件-->
<!-- =================================================================== -->
<target name="clean" depends="init">
<delete dir="${basedir}/build" />
</target>
</project>
- build.properties
#工程前缀
project.perfix=empi
#工程名称
product.name=core
#工程版本号
product.version=1.0
#编译作者
user.name=
#公司名称
company.name=supcon
#以下变量暂未用,以后扩展
thirdParty.include.jar=*.jar
thirdParty.exclude.jar=
internal.include.jar=*.jar
internal.exclude.jar=