« | September 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | | | | |
| 公告 |
关注电子政务、大型企业应用开发、Web、Workflow、MOM、MDA、RCP、GEF email:gmluyang@gmail.com
|
Blog信息 |
blog名称:SixSun的Blog 日志总数:152 评论数量:372 留言数量:13 访问次数:2383974 建立时间:2004年12月13日 |

| |
[Java Open Source]Ant-Build.xml 原创空间, 软件技术
SixSun 发表于 2005/4/10 14:25:43 |
clover 部分还是有些问题,并且需要下载clover和clover.license(有一个月的试用期) ,将clover.jar和clover.license放入Ant的lib中。
clover下载地址:http://www.cenqua.com/
Ant-Build.xml
<?xml version="1.0"?>
<project name="MouseCatchDog" default="deploy">
<!-- project property definition --> <property name="project.name" value="MouseCatchDog" /> <property name="deploy.name" value="MouseCatchDog" /> <property name="project.war" value="MouseCatchDog" /> <!-- tomcat home path property definition --> <property name="tomcat.home" location="D:\Java\Tomcat\Tomcat-5.0.28" /> <property name="deploy.dir" location="${tomcat.home}/webapps/${deploy.name}/" /> <!-- src path property definition --> <property name="src.dir" location="src"/> <property name="src.java.dir" location="${src.dir}/java"/> <property name="src.test.dir" location="${src.dir}/test"/> <!-- target path property definition --> <property name="target.dir" location="target"/> <property name="target.classes.java.dir" location="${target.dir}/classes/java"/> <property name="target.classes.test.dir" location="${target.dir}/classes/test"/> <property name="target.report.dir" location="${target.dir}/report"/> <!-- common web property definition --> <property name="web.dir" location="web" /> <property name="build.dir" location="${web.dir}/WEB-INF/classes" /> <!-- lib path property definition --> <property name="lib.dir" location="${web.dir}/WEB-INF/lib" /> <property name="lib2.dir" location="lib" /> <!-- classpath definition --> <path id="master-classpath"> <fileset file="${lib.dir}/*.jar" /> <fileset file="${lib2.dir}/*.jar" /> <pathelement path="${build.dir}"/> </path>
<!-- do some init work --> <target name="init"> <echo>################################################### * Created on 2005-5-1# * Copyright (C) 2005 Guangdong ZS Lu.Yang. # * Author Luyang, Copyright (C) 2005, Luyang.# * Email luyang.mail@163.com# * Blog blogger.org.cn/sixsun ################################################## </echo> </target> <!-- compile java --> <target name="compile.java" depends="init" description="compile the source files"> <mkdir dir="${target.classes.java.dir}"/> <javac srcdir="${src.java.dir}" destdir="${target.classes.java.dir}" target="1.4"> <classpath refid="master-classpath"/> </javac> <mkdir dir="${build.dir}"/> <javac srcdir="${src.java.dir}" destdir="${build.dir}" target="1.4"> <classpath refid="master-classpath"/> </javac> </target> <!-- compile test --> <target name="compile.test" depends="compile.java"> <mkdir dir="${target.classes.test.dir}"/> <javac destdir="${target.classes.test.dir}"> <src path="${src.test.dir}"/> <classpath> <pathelement location="${target.classes.java.dir}"/> </classpath> <classpath refid="master-classpath"/> </javac> </target> <!-- compile java and test --> <target name="compile" depends="compile.java,compile.test"/> <!-- run junit test --> <target name="test" depends="compile"> <mkdir dir="${target.report.dir}"/> <property name="tests" value="TestDefaultController"/> <junit printsummary="yes" haltonerror="yes" haltonfailure="yes"> <formatter type="plain" usefile="false"/> <formatter type="xml"/> <batchtest todir="${target.report.dir}"> <fileset dir="${src.test.dir}"> <include name="**/${tests}.java"/> <exclude name="**/Test*All.java"/> </fileset> </batchtest> <classpath> <pathelement location="${target.classes.java.dir}"/> <pathelement location="${target.classes.test.dir}"/> <pathelement path="${ant.home}/lib/clover.jar"/> </classpath> </junit> </target> <!-- create report file --> <target name="report" depends="test"> <mkdir dir="${target.report.dir}/html"/> <junitreport todir="${target.report.dir}"> <fileset dir="${target.report.dir}"> <include name="TEST-*.xml"/> </fileset> <report todir="${target.report.dir}/html"/> </junitreport> </target> <!-- compress to .war file --> <target name="pack" depends="report" description="make .war file"> <jar destfile="./${project.war}.war" basedir="${web.dir}"> <exclude name="**/*Test.*" /> <exclude name="**/Test*.*" /> </jar> </target>
<!-- deploy --> <target name="deploy" depends="pack" description="deploy the application"> <mkdir dir="${deploy.dir}"/> <copy todir="${deploy.dir}"> <fileset dir="${web.dir}"> <include name="**/*.*" /> </fileset> </copy> </target> <!-- api doc --> <target name="apidoc" depends="compile" description="create api doc"> </target>
<!-- clean target --> <target name="clean"> <delete dir="${target.dir}"/> </target>
<!-- clover init --> <target name="clover.init"> <taskdef resource="clovertasks"/> <clover-setup initString="${target.dir}/clover_coverage.db"> <files> <exclude name="**/Test*.java"/> </files> </clover-setup> </target>
<!-- clover --> <target name="clover" depends="clean,clover.init,test"> <clover-report> <current outfile="${target.dir}/clover" title="Clover Report"> <format type="html"/> </current> </clover-report> </target>
<!-- send a mail --> <!--
</project> |
|
回复:Ant-Build.xml 原创空间, 软件技术
SixSun发表评论于2006/1/3 21:10:30 |
另一个Ant脚本
<?xml version="1.0"?><project name="ThoughtSpring" basedir="." default="usage"> <property file="build.properties" /> <property name="src.main.dir" value="src/main/java" /> <property name="src.test.dir" value="src/test/java" /> <property name="web.dir" value="WebContent" /> <property name="build.dir" value="${web.dir}/WEB-INF/classes" /> <property name="test.dir" value="${web.dir}/WEB-INF/test-classes" /> <property name="name" value="ThoughtSpring" /> <path id="master-classpath"> <fileset dir="${web.dir}/WEB-INF/lib"> <include name="*.jar" /> </fileset> <!-- We need the servlet API classes: --> <!-- for Tomcat 4.1 use servlet.jar --> <!-- for Tomcat 5.0 use servlet-api.jar --> <!-- for Other app server - check the docs --> <fileset dir="${appserver.home}/common/lib"> <include name="servlet*.jar" /> </fileset> <pathelement path="${build.dir}" /> </path> <target name="usage"> <echo message="" /> <echo message="${name} build file" /> <echo message="-----------------------------------" /> <echo message="" /> <echo message="Available targets are:" /> <echo message="" /> <echo message="deploy --> Deploy application as directory" /> <echo message="deploywar --> Deploy application as a WAR file" /> <echo message="build --> Build the application" /> <echo message="junit --> Run JUnit Tests" /> <echo message="clean --> Clean output directories" /> <echo message="undeploy --> Un-Deploy application" /> <echo message="list --> List Tomcat applications" /> <echo message="install --> Install application in Tomcat" /> <echo message="start --> Start Tomcat application" /> <echo message="reload --> Reload application in Tomcat" /> <echo message="stop --> Stop Tomcat application" /> <echo message="" /> </target> <target name="deploy" depends="build,clean,undeploy" description="Deploy application"> <copy todir="${deploy.path}/${name}" preservelastmodified="true"> <fileset dir="${web.dir}"> <include name="**/*.*" /> </fileset> </copy> <echo message="::deploy - Deploy application as directory" /> <echo message="::deploy - application : ${web.dir} " /> <echo message="::deploy - directory : ${deploy.path}/${name} " /> </target> <target name="deploywar" depends="build,clean,undeploy" description="Deploy application as a WAR file"> <war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml"> <fileset dir="${web.dir}"> <include name="**/*.*" /> </fileset> </war> <copy todir="${deploy.path}" preservelastmodified="true"> <fileset dir="."> <include name="*.war" /> </fileset> </copy> <echo message="::deploywar --> Deploy application as a WAR file" /> <echo message="::deploywar - destfile : ${name}.war" /> <echo message="::deploywar - webxml : ${web.dir}/WEB-INF/web.xml" /> <echo message="::deploywar - fileset : ${web.dir}" /> <echo message="::deploywar - deploy path : ${deploy.path}" /> </target> <target name="build" description="Compile main source tree java files"> <echo message="::build --> Build the application" /> <mkdir dir="${build.dir}" /> <javac destdir="${build.dir}" target="1.3" debug="true" deprecation="false" optimize="false" failonerror="true"> <src path="${src.main.dir}" /> <classpath refid="master-classpath" /> </javac> <echo message="::build - --> make build.dir : ${build.dir}" /> <echo message="::build - --> src.main.dir : ${src.main.dir}" /> <echo message="::build - --> build.dir : ${build.dir}" /> <mkdir dir="${test.dir}" /> <javac destdir="${test.dir}" target="1.3" debug="true" deprecation="false" optimize="false" failonerror="true"> <src path="${src.test.dir}" /> <classpath refid="master-classpath" /> </javac> <echo message="::build - --> make test.dir : ${test.dir}" /> <echo message="::build - --> src.test.dir : ${src.test.dir}" /> <echo message="::build - --> test.dir : ${test.dir}" /> </target> <target name="junit" depends="build" description="Run JUnit Tests"> <junit printsummary="on" fork="false" haltonfailure="false" failureproperty="tests.failed" showoutput="true"> <classpath refid="master-classpath"/> <formatter type="brief" usefile="false"/>
<batchtest> <fileset dir="${test.dir}"> <include name="**/Test*.*"/> </fileset> </batchtest>
</junit>
<fail if="tests.failed"> tests.failed=${tests.failed} *********************************************************** *********************************************************** **** One or more tests failed! Check the output ... **** *********************************************************** *********************************************************** </fail> </target> <target name="clean" description="Clean output directories"> <delete> <fileset dir="${build.dir}"> <include name="**/*.class"/> </fileset> </delete> <echo message="::clean --> Clean output directories" /> <echo message="::clean - Output dir : ${build.dir}" /> </target>
<target name="undeploy" description="Un-Deploy application"> <delete> <fileset dir="${deploy.path}/${name}"> <include name="**/*.*"/> </fileset> </delete> <echo message="::undeploy --> Un-Deploy application" /> <echo message="::undeploy - Deploy dir : ${deploy.path}/${name}" /> </target> <!-- ============================================================== --> <!-- Tomcat tasks - remove these if you don't have Tomcat installed --> <!-- ============================================================== --> <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"> <classpath> <path location="${appserver.home}/server/lib/catalina-ant.jar" /> </classpath> </taskdef> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"> <classpath> <path location="${appserver.home}/server/lib/catalina-ant.jar" /> </classpath> </taskdef> <taskdef name="list" classname="org.apache.catalina.ant.ListTask"> <classpath> <path location="${appserver.home}/server/lib/catalina-ant.jar" /> </classpath> </taskdef> <taskdef name="start" classname="org.apache.catalina.ant.StartTask"> <classpath> <path location="${appserver.home}/server/lib/catalina-ant.jar" /> </classpath> </taskdef> <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"> <classpath> <path location="${appserver.home}/server/lib/catalina-ant.jar" /> </classpath> </taskdef> <target name="install" description="Install application in Tomcat"> <install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" war="${name}" /> </target> <target name="reload" description="Reload application in Tomcat"> <reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" /> </target> <target name="start" description="Start Tomcat application"> <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" /> </target> <target name="stop" description="Stop Tomcat application"> <stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" /> </target> <target name="list" description="List Tomcat applications"> <list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" /> </target> <!-- End Tomcat tasks --></project>
|
|
» 1 »
|