<project
  default="xdoc:transform"
  xmlns:deploy="deploy">



  <!-- Allow any user specific values to override the defaults -->
  <property file="${user.home}/build.properties" />
  <!-- Allow user defaults for this project -->
  <property file="build.properties" />
  <!-- Set default values for the build -->
  <property file="default.properties" />

  <!-- ================================================================== -->
  <!-- C O M P I L E   P O S T   G O A L                                  -->
  <!-- ================================================================== -->
  <!-- copies the templates, dtd, .. to the ${maven.build.dest} to        -->
  <!-- include them in the jar file                                       -->
  <!-- ================================================================== -->

  <postGoal name="java:compile">


    <!-- copy database.dtd to the right place -->


<!--copy todir="target/WEB-INF"-->
<!--
<!copy todir="${build.home}/WEB-INF">
      <fileset dir="${maven.src.dir}/../etc" />
    </copy>
-->
   
  </postGoal>

  <!-- ================================================================== -->
  <!-- D I S T : B U I L D _ B I N   P R E   G O A L                      -->
  <!-- ================================================================== -->
  <!-- copies jars, templates, ... to the ${maven.dist.bin.assembly.dir}  -->
  <!-- to include them in the binary dists                                -->
  <!-- ================================================================== -->

  <preGoal name="dist:build-bin">

<copy todir="${maven.dist.bin.assembly.dir}/WEB-INF">
      <fileset dir="${maven.src.dir}/etc" />
    </copy>

    <!-- copy templates to the right place -->

    <copy todir="${maven.dist.bin.assembly.dir}/templates">
      <fileset dir="${maven.src.dir}/templates" />
    </copy>

    <!-- copy schema files to the right place -->
    <copy todir="${maven.dist.bin.assembly.dir}/schema">
      <fileset dir="${maven.src.dir}/schema" />
    </copy>

    <!-- copy master files to the right place -->
    <copy todir="${maven.dist.bin.assembly.dir}/master">
      <fileset dir="${maven.src.dir}/conf/master" />
    </copy>

    <!-- copy config files to the right place -->
    <copy todir="${maven.dist.bin.assembly.dir}">
      <fileset dir="${maven.src.dir}/conf" />
    </copy>

    <!-- include listed dependencies -->
    <deploy:copy-deps todir="${maven.dist.bin.assembly.dir}/lib"/>

    <!-- move torque.jar to /lib -->
    <move
      file="${maven.dist.bin.assembly.dir}/${maven.final.name}.jar"
      todir="${maven.dist.bin.assembly.dir}/lib"
    />

  </preGoal>

  <!-- ================================================================== -->
  <!-- R U N T I M E T E S T                                              -->
  <!-- ================================================================== -->
  <goal
   name="starstation:def"
   prereqs="site:generate"
   description="Target starstation">
 
<!--
  <ant antfile="build-test.xml"
      inheritAll="true"
/> 
-->
</goal>
  <goal
    name="runtime:test"
    prereqs="runtime:prepare"
    description="runtime tests (set torque.testProfile in your build.properties)">

    <ant antfile="build-test.xml"
         dir="${torque.distDir}"
         inheritAll="false"/>
  </goal>

  <goal
    name="runtime:test-classpath"
    prereqs="runtime:prepare"
    description="runtime tests using useClasspath property (set torque.testProfile in your build.properties)">

    <ant antfile="build-test.xml"
         dir="${torque.distDir}"
         target="test-classpath"
         inheritAll="false"/>
  </goal>

  <goal
    name="runtime:prepare"
    prereqs="java:jar">

    <!-- Set values in test profile -->
    <property file="${torque.testProfile}"/>

    <!-- Use the profile as the build.properties file
         in the dist directory so that it is customizable
         by each tester. -->
    <echo message="Copying profile into distribution directory: ${torque.testProfile}"/>

    <filter token="DATABASE_DEFAULT" value="${torque.defaultDatabase}"/>
    <filter token="DATABASE_URL" value="${torque.database.url}"/>
    <filter token="DATABASE_USER" value="${torque.database.user}"/>
    <filter token="DATABASE_DRIVER" value="${torque.database.driver}"/>
    <filter token="DATABASE_PASSWORD" value="${torque.database.password}"/>
    <filter token="DATABASE_ID_METHOD" value="${torque.idMethod}"/>
    <filter token="DATABASE_ADAPTER" value="${torque.database}"/>

    <copy
      tofile="${torque.distDir}/build.properties"
      file="${torque.testProfile}"
      overwrite="yes"
    />

    <!-- copy test schemas -->
    <copy
      todir="${torque.distDir}/schema"
      filtering="yes"
      overwrite="yes">
      <fileset dir="${rttest.dir}">
        <include name="**/*.xml"/>
      </fileset>
    </copy>

    <!-- copy test sources -->
    <copy todir="${torque.distDir}/src/java">
      <fileset dir="${rttest.dir}"/>
    </copy>

    <!-- copy ant build files -->
    <copy
      tofile="${build.test}/rttest/build-test.xml"
      file="${src.dir}/rttest/build-test.xml"
      overwrite="yes"
    />
    <copy
      tofile="${build.test}/rttest/build-torque.xml"
      file="${src.dir}/conf/build-torque.xml"
      overwrite="yes"
    />
    <copy
      tofile="${build.test}/rttest/default.properties"
      file="${src.dir}/conf/default.properties"
      overwrite="yes"
    />

    <!-- copy libs -->
    <deploy:copy-deps todir="${build.test}/rttest/lib"/>
    <copy file="${maven.build.dir}/${maven.final.name}.jar"
          todir="${build.test}/rttest/lib"/>
    <copy file="${torque.testDatabaseJar}"
          todir="${build.test}/rttest/lib"/>

    <!-- copy templates -->
    <copy todir="${build.test}/rttest/templates">
      <fileset dir="${src.dir}/templates"/>
    </copy>

    <!-- copy Torque.properties -->
    <copy
      todir="${build.test}/rttest"
      file="src/rttest/Torque.properties"
      filtering="yes"
    />

  </goal>


</project>
