欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

ant build.xml示范

更新时间: 2014-01-05 02:01:04 责任编辑: Author_N1

 

ant build.xml示例
<?xml version="1.0" encoding="utf-8" ?>
<project default="all" basedir=".">
	<property environment="env" />
	<property name="appname" value="virt" />
	<property name="jarname" value="yoyo-virt" />
	<property name="mainclass" value="com.yoyosys.virt.navigation.service.SystemResourceMonitor" />
	<property name="src" value="src" />
	<property name="conf" value="conf" />
	<property name="build" value="${basedir}/build" />
	<property name="build.src" value="${build}/src" />
	<property name="build.class" value="${build}/class" />
	<property name="build.doc" value="${build}/doc" />

	<property name="debug" value="off" />
	<property name="optimize" value="on" />
	<property name="deprecation" value="on" />
	<property name="packages" value="com.yoyosys.virt.*" />

	<path id="classpath">
		<fileset dir="./WebContent/WEB-INF/lib">
			<include name="*.jar" />
		</fileset>
		<fileset dir="./lib">
			<include name="*.jar" />
		</fileset>
	</path>

	<target name="all" depends="init,build,jar" description="make all task." />

	<target name="init" depends="clean">
		<mkdir dir="${build}" />
		<mkdir dir="${build.src}" />
		<mkdir dir="${build.class}" />
		<mkdir dir="${build.doc}" />
		<copy todir="${build.src}">
			<fileset dir="${src}" />
			<fileset dir="${conf}" />
		</copy>
	</target>

	<target name="build" depends="init">
		<javac srcdir="${build.src}" destdir="${build.class}" encoding="UTF-8" debug="${debug}" optimize="${optimize}" deprecation="${deprecation}" includeantruntime="on">
			<include name="com/**/*.java" />
			<classpath refid="classpath" />
		</javac>
		<copy todir="${build.class}">
			<fileset dir="${build.src}">
				<include name="handlers/*" />
				<include name="rdb/*" />
			</fileset>
		</copy>
	</target>

	<target name="javadoc" depends="init">
		<javadoc packagenames="${packages}" sourcepath="${build.src}" destdir="${build.doc}" author="true" version="true" use="true" splitindex="true" windowtitle="${appname} API" doctitle="${appname}" charset="UTF-8" encoding="UTF-8" docencoding="UTF-8">
			<classpath refid="classpath" />
		</javadoc>
	</target>

	<target name="jar" depends="build">
		<pathconvert property="libs.project" pathsep=" ">
			<mapper>
				<chainedmapper>
					<!-- remove absolute path -->
					<flattenmapper />
					<!-- add lib/ prefix -->
					<globmapper from="*" to="lib/*" />
				</chainedmapper>
			</mapper>
			<path refid="classpath" />
		</pathconvert>

		<jar jarfile="${build}/${jarname}.jar" basedir="${build.class}" includes="**">
			<manifest>
				<attribute name="Main-Class" value="${mainclass}" />
				<attribute name="Class-Path" value="${libs.project}" />
			</manifest>
		</jar>
		<jar jarfile="${build}/${jarname}-doc.jar" basedir="${build.doc}" includes="**" />
		<jar jarfile="${build}/${jarname}-src.jar" basedir="${build.src}" includes="**" />
	</target>

	<target name="clean" description="clean up">
		<delete dir="${build}" />
	</target>

	<!-- checkstyle -->
	<property name="checkstyle-5.3.home" value="${env.YOYO_SVN_HOME}/app/java/checkstyle/checkstyle-5.3" />

	<fileset id="checkstyle-5.3.jar" dir="${checkstyle-5.3.home}">
		<include name="checkstyle-5.3-all.jar" />
	</fileset>

	<property name="checkstyle-latest.home" value="${checkstyle-5.3.home}" />
	<fileset id="checkstyle-latest.jar" refid="checkstyle-5.3.jar" />
	<taskdef resource="checkstyletask.properties" classpath="${checkstyle-5.3.home}/checkstyle-5.3-all.jar" />

	<target name="checkstyle" depends="build">
		<checkstyle config="${env.YOYO_SVN_HOME}/app/java/checkstyle/checkstyle.xml" failOnViolation="false">
			<fileset dir="${build.src}/com/yoyosys/virt">
				<include name="**/*.java" />
			</fileset>
			<formatter type="plain" />
			<formatter type="xml" toFile="${build}/checkstyle_report.xml" />
		</checkstyle>
		<xslt in="${build}/checkstyle_report.xml" out="${build}/checkstyle_report.html" style="${basedir}/checkstyle-noframes-severity-sorted.xsl" />
		<delete file="${build}/checkstyle_report.xml" />
	</target>

	<!-- findbugs -->
	<property name="findbugs.home" value="${env.YOYO_SVN_HOME}/app/java/findbugs/findbugs-2.0.0" />
	<path id="findbugs-jar">
		<pathelement path="${findbugs.home}/lib/findbugs-ant.jar" />
	</path>
	<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs-jar" />

	<target name="findbugs" depends="build">
		<findbugs home="${findbugs.home}" jvmargs="-server -Xss512m -Xmx1024m" output="xml:withMessages" outputFile="${build}/findbugs_report.xml" excludefilter="${basedir}/findbugs_exclude.xml" auxClasspathRef="classpath">
			<sourcePath path="${build.src}" />
			<class location="${build.class}" />
		</findbugs>
		<xslt in="${build}/findbugs_report.xml" out="${build}/findbugs_report.html" style="${basedir}/findbugs-fancy-hist.xsl" />
		<delete file="${build}/findbugs_report.xml" />
	</target>
</project>

上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 02:01:04
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/4536/
本文WWW.DOC100.NET DOC100.NET版权所有。