<project name="jetty build" basedir=".." default="package">
  <property name="src.dir" value="src/main/java"/>
  <property name="test.dir" value="src/test/java"/>
  <property name="rsrc.dir" value="src/main/resources"/>
  <property name="config.dir" value="src/main/config/etc"/>
  <property name="build.dir" value="${basedir}/build"/>
  <property name="target.dir" value="${basedir}/target"/>
  <property name="lib.dir" value="${basedir}/lib"/>
  <property name="etc.dir" value="${basedir}/etc"/>
  <property name="javadoc.dir" value="${basedir}/api"/>
  <property name="module.script" location="debian/module.xml"/>

  <path id="classpath">
    <fileset dir="${target.dir}">
      <include name="**/*.jar"/>
    </fileset>
  </path>

  <target name="package">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${target.dir}"/>
    <mkdir dir="${lib.dir}"/>
    <mkdir dir="${etc.dir}"/>
    
    <ant dir="${basedir}/modules/util/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-util"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}"/>
      <property name="run-tests" value="true"/>
    </ant>
    
    <ant dir="${basedir}/modules/util5/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-util5"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/util5"/>
      <property name="run-tests" value="true"/>
    </ant>
    
    <ant dir="${basedir}/modules/jetty/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}"/>
      <property name="run-tests" value="true"/>
    </ant>
    
    <ant dir="${basedir}/extras/sslengine/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-sslengine"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/sslengine"/>
    </ant>
    
    <ant dir="${basedir}/modules/start/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-start"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${basedir}"/>
      <property name="jar.main.class" value="org.mortbay.start.Main"/>
      <property name="jar.file" value="start.jar"/>
    </ant>
    
    <ant dir="${basedir}/contrib/start-daemon/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-start-daemon"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${basedir}"/>
      <property name="jar.main.class" value="org.mortbay.jetty.start.daemon.Bootstrap"/>
      <property name="jar.file" value="start-daemon.jar"/>
    </ant>
    
    <!-- EXTRAS -->
    
    <ant dir="${basedir}/modules/html/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-html"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>
    
    <ant dir="${basedir}/modules/management/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-management"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/management"/>
    </ant>
    
    <ant dir="${basedir}/modules/naming/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-naming"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/naming"/>
    </ant>
    
    <ant dir="${basedir}/extras/servlet-tester/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-servlet-tester"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>
    
    <ant dir="${basedir}/extras/ajp/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-ajp"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>
    
    <ant dir="${basedir}/extras/setuid/modules/java/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-setuid"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>
    
    <ant dir="${basedir}/extras/threadpool/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-java5-threadpool"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>
    
    <ant dir="${basedir}/extras/client/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-client"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>
    
    <ant dir="${basedir}/contrib/jetty-rewrite-handler/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-rewrite-handler"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>

     <ant dir="${basedir}/modules/plus/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-plus"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/plus"/>
    </ant>

     <ant dir="${basedir}/modules/annotations/" antfile="${module.script}" inheritRefs="true">
      <property name="module-name" value="jetty-annotations"/>
      <property name="module-version" value="${VERSION}"/>
      <property name="module-libdir" value="${lib.dir}/ext"/>
    </ant>
  
    <copy file="${basedir}/modules/jetty/src/main/resources/org/mortbay/jetty/webapp/webdefault.xml" todir="${etc.dir}"/>
    <copy file="${basedir}/debian/start.config" todir="${etc.dir}"/>
    <copy file="${basedir}/debian/jetty.conf" todir="${etc.dir}"/>
    <copy file="${basedir}/debian/jetty-extra.conf" todir="${etc.dir}"/>
  </target>
  
  <target name="clean">
    <delete dir="${build.dir}" quiet="true"/>
    <delete>
      <fileset dir="${basedir}/modules" includes="**/test/java/**/*.class"/>
    </delete>
    <delete dir="${target.dir}" quiet="true"/>
    <delete dir="${lib.dir}" quiet="true"/>
    <delete dir="${etc.dir}" quiet="true"/>
    <delete includeemptydirs="true" quiet="true">
      <fileset dir="${javadoc.dir}" excludes="contents.html"/>
    </delete>
    <delete file="${basedir}/start.jar" quiet="true"/>
    <delete file="${basedir}/start-daemon.jar" quiet="true"/>
    <delete file="${basedir}/extras/setuid/modules/native/target/generated/org_mortbay_setuid_SetUID.c" quiet="true"/>
    <delete file="${basedir}/extras/setuid/modules/native/target/generated/org_mortbay_setuid_SetUID.h" quiet="true"/>
  </target>
  
</project>

