byterat

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  54 随笔 :: 0 文章 :: 15 评论 :: 0 Trackbacks

<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="compile" basedir=".">
  <!-- define the properties for target reference -->
  <property name="dir.src" value="src"/>
  <property name="dir.etc" value="etc"/>  
  <property name="dir.web" value="web"/>
  <property name="dir.meta" value="meta"/>  
  <property name="dir.lib" value="${dir.web}/WEB-INF/lib"/>
  <property name="dir.build" value="${dir.web}/WEB-INF"/>
  <property name="dir.classes" value="${dir.web}/WEB-INF/classes"/>
  <property name="app.name" value="ocs"/>

  <!-- data base -->  
  <property file="${dir.web}/WEB-INF/config/jdbc.properties"/>  
  <property name="database.driver"   value="${jdbc.driverClassName}"/>
  <property name="database.url"      value="${jdbc.url}"/>
  <property name="database.username" value="${jdbc.username}"/>
  <property name="database.password" value="${jdbc.password}"/>

  <!-- the classpth of ant -->
  <path id="classpath">
    <fileset dir="${dir.lib}" includes="**/*.jar" />
    <pathelement path="${dir.classes}"/>
  </path>


  <!-- compile the src and test source code -->
  <target name="compile" description="Compile main source and test tree java files">
   <delete dir="${dir.classes}"/>   
   <mkdir dir="${dir.classes}"/>
    <javac srcdir="${dir.src}" destdir="${dir.classes}" debug="on">
      <classpath refid="classpath"/>
    </javac>
    <copy todir="${dir.classes}">
      <fileset dir="${dir.src}" includes="**/*.xml,**/*.properties">
          <!--exclude name="**/*.hbm.xml" /-->
      </fileset>
      <fileset dir="${dir.etc}" includes="**/*.properties"/>
    </copy>
  <native2ascii dest="${dir.classes}" src="${dir.etc}" encoding="UTF-8" includes="**/*.src" ext=".properties" />
  </target>

 
  <!-- setup the database and initialize the data -->
  <target name="setup-db">
    <echo message="=========================================================="/>
    <echo message="database driver:${database.driver}"/>
    <echo message="database
url:${database.url}"/ >
    <echo message="database username:${database.username}"/>
    <echo message="database password:${database.password}"/>
    <echo message="=========================================================="/>  
   
    <antcall target="runSql" inheritAll="false">
      <param name="script.sql" value="${dir.meta}/database-setup.sql"/>
      <param name="database.driver" value="${database.driver}"/>
      <param name="database.url" value="${database.url}"/>
      <param name="database.username" value="${database.username}"/>
      <param name="database.password" value="${database.password}"/>
    </antcall>
    <echo message="initialize Sample data..."/>
    <antcall target="runSql" inheritAll="false">
      <param name="script.sql" value="${dir.meta}/database-init.sql"/>
      <param name="database.driver" value="${database.driver}"/>
      <param name="database.url" value="${database.url}"/>
      <param name="database.username" value="${database.username}"/>
      <param name="database.password" value="${database.password}"/>
    </antcall>
  </target>
  
 
  <!-- run the sql to setup database -->
  <target name="runSql">
    <sql src="${script.sql}"
         driver="${database.driver}"
         url="${database.url}"
         userid="${database.username}"
         password="${database.password}"
         classpathref="classpath"
         onerror="continue"/>
  </target>

  <target name="clean" description="Clean output directories">
    <delete dir="${dir.classes}"/>
  </target>
 
   
  <target name="deploy" description="deploy......" depends="clean,compile" >
  </target>
</project>

posted on 2006-11-08 09:47 比特鼠 阅读(189) 评论(0)  编辑  收藏 所属分类: Java