通用模块common.xml build.xml

<?xml version="1.0" encoding="utf-8"?>
<project>
<property name="build.dir" value="dest"/>
<property name="src.dir" value="src"/>
<property name="etc.dir" value="etc"/>
<property name="lib.dir" value="../appdemo/lib"/>
<property name="buildlib.dir" value="../appdemo/buildlib"/>
<property name="web.dir" value="web"/>
<property environment="env"/>
<property name="tomcat.home" value="${env.Tomcat_home}"/>

<path  id="classpath">
<fileset dir="${lib.dir}">
   <include name="*.jar"/>
</fileset>
<fileset dir="${tomcat.home}/common/lib">
   <include name="*.jar"/>
</fileset>
     <pathelement path="${build.dir}/classes"/>
</path>
<path id="buildclasspath">
<path refid="classpath"/>
<fileset dir="${buildlib.dir}">
<include name="*.jar"/>
</fileset>
</path>

<!--==========================================================-->
<!--==The help target is used to display the helping message==-->
<!--==========================================================-->
<target name="help">
  <echo message=""/>
  <echo message="${webapp.name} build file"/>
  <echo message="===================================="/>
  <echo message=""/>
  <echo message="Available targets are:"/>
  <echo message=""/>
  <echo message="help   --> Print this screen"/>
  <echo message="compile --> Compile all Java files"/>
</target>
<!--==========================================================-->
<!--==The Compile target is used to compile project and copy==-->
<!--==Hibernate configuration file to the proper direction. ==-->
<!--==========================================================-->
<target name="compile" description="compile the java source and copy the configuration file">
  <mkdir dir="${build.dir}/classes"/>
  <javac destdir="${build.dir}/classes" target="1.5" source="1.5" debug="true" deprecation="true" optimize="false" failonerror="true">
    <src path="${src.dir}"/>
    <classpath refid="classpath"/>
   </javac>
   <!-- copy hibernate mapping files to ${build.dir}/classes-->
   <copy todir="${build.dir}/classes">
      <fileset dir="${src.dir}" includes="**/*.hbm.xml"/>
   </copy>
   <copy todir="${src.dir}/classes">
      <fileset todir="${etc.dir}/classes" includes="**/*.xml"/>
       <fileset todir="${etc.dir}/classes" includes="**/*.properties">
       <exclude name="**/*_zh.properties"/>
       </fileset>
   </copy>

<native2ascii dest="${build.dir}/classes" encoding="utf-8"
src="${etc.dir}/classes" includes="**/*_zh.properties"></native2ascii>
</target>
<!--==========================================================-->
<!--==The deploy target is used to deploy project and copy  ==-->
<!--==the configuration file to the tomcat container        ==-->
<!--==========================================================-->
<target name="deploy" depends="compile" description="deploy the project to the tomcat">
<!--copy the web file-->
  <copy todir="${tomcat.home}/webapps/${webapp.name}" preservelastmodified="true">
     <fileset dir="${web.dir}">
       <include name="**/*.*"/>
     <exclude name="**/readme.txt"/>
      </fileset>
  </copy>
<!--copy the classes file-->
  <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF/classes" preservelastmodified="true">
    <fileset dir="${build.dir}/classes">
  </fileset>
  </copy>
<!--copy the lib file-->
  <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF/lib" preservelastmodified="true">
   <fileset dir="${lib.dir}">
   <exclude name="**/readme.txt"/>
    </fileset>
  </copy>
<!--copy the configuration file-->
  <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF" preservelastmodified="true">
   <fileset dir="${etc.dir}">
     <exclude name="**/readme.txt"/>
      </fileset>
  </copy>
</target>
<!--==========================================================-->
<!--==The clean target is used to clean output directories  ==-->
<!--==========================================================-->
<target name="clean" description="Clean output directories">
   <delete dir="${build.dir}"/>
   <delete dir="${tomcat.home}/webapps/${webapp.name}"/>
</target>
<!--==========================================================-->
<!--==The new target is used to create a new project by========-->
<!--== duplicationg this project and replacing "message" instances with the new name-->
<!--==========================================================-->
<target name="new" description="creates a new project with the specified name">
   <echo level="info">
   +------------------------------------------------------------+
   |  ---Welcome to the AppDemo New Application Wizard!--       |
   |                                                            |
   |  To create a new application ,please answer the following  |
   |  question.                                                 |
   +------------------------------------------------------------+
  
   </echo>
   <echo/>
<!--Prompt user for input-->
   <input message="What would you like to name your application{myapp}?" addproperty="app.name" defaultvalue="myapp"/>
<echo level="info">Creating new application named "${app.name}".. </echo>
   <copy todir="../${app.name}">
     <fileset dir="${basedir}">
     <exclude name="**/*.jar"/>
     <exclude name="common.xml"/>
     </fileset>
   </copy>
    <!--replace app name-->
<replaceregexp flags="g">
   <regexp pattern="message"/>
   <substitution expression="${app.name}"/>
   <fileset dir="../${app.name}">
     <include name="**"/>
   <exclude name="**/*.jar"/>
   </fileset>
</replaceregexp>
</target>
<!--==========================================================-->
<!--==The "test" target is used to execute the unit test by junit-->
<!--==========================================================-->
<target name="test" description="Run junit test.">
  <junit printsummary="true">
  <formatter type="xml"/>
  <test name="cn.hxex.message.test.AllTests"/>
  <classpath refid="classpath"/>
  </junit>
  <junitreport todir="${build.dir}/test">
  <fileset dir=".">
       <include name="TEST-*.xml"/>
  </fileset>
    <report format="noframes" todir="${build.dir}/report"/>
  </junitreport>
</target>
</project>











<?xml version="1.0" encoding="utf-8"?>
<project name="appdemo" basedir="." default="help">
<property name="webapp.name" value="appdemo"/>
<import file="../appdemo/common.xml"/>
</project>




你可能感兴趣的:(tomcat,xml,Hibernate,Web,JUnit)