<?xml version="1.0"?>
<!--
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->
<!-- 
Simplistic meta-build file to call various other xml-commons build files.
Currently merely uses <ant> to build all subprojects, then 
just creates a distribution out of all of them.
@author shane_curcuru@us.ibm.com
-->
<project name="xml-commons" default="all">

  <!-- Allow properties following these statements to be overridden -->
  <property file="build.properties"/>

  <!-- Name and version information -->
  <!-- NOTE: In the future, it's likely we will be releasing each 
       component individually, so there really isn't a need for a 
       version number for the whole xml-commons project.  This section
       and the distro stuff in this file needs to be reworked.
       Note, however, the docs section in this file, esp. forrest stuff, 
       should be kept for the whole xml-commons project. Sep-03 -sc
  -->
  <!-- Versions similar to Xalan builds: major.minor [isbeta release | release] 
       Version flow: 
        Beta builds leading up to 1.0 gold: 1.0.b1, 1.0.b2, ... 
         Decide on a gold build: 1.0
        Beta builds leading up to a 1.1 point release with new features: 1.1.b1, ...
         Decide on a gold build: 1.1 
        Ooops! Bugfix needed to 1.0 build: fork, then release 1.0.1
        etc.
       version.isbeta is 'b' for beta releases leading up to 
       a major release; it's blank for gold builds and for 
       any later point releases that fork from a previous gold.
  -->
  <property name="version.major" value="1"/>
  <property name="version.minor" value="0"/>
  <property name="version.isbeta" value="b"/><!-- values: 'b'|'' -->
  <property name="version.release" value="3"/>
  <property name="version" value="${version.major}.${version.minor}.${version.isbeta}${version.release}" />
  
  <!-- Location of the system's temporary directory; all output sent here -->
  <property name="tmp.dir" value="."/>

  <!-- Overall distribution unit -->
  <property name="dist.basename" value="xml-commons-${version}"/> 
  <property name="dist.dir" value="${tmp.dir}/build"/>

  <property name="site.dir" value="${dist.dir}/site"/>
  <property name="docs.content.dir" value="src/documentation/content"/>

  <!-- Public Targets -->
  <target name="all"
          depends="jars,javadocs,dist"
          description="Default all target; calls every sub-build file directly.">
  </target>

  <target name="external"
          description="Calls just java/external/build.xml only.">
    <ant dir="java/external" antfile="build.xml" target="all" >
    </ant>
  </target>

  <target name="jars"
          depends="external" 
          description="Calls all other java build files.">
    <ant dir="java" antfile="which.xml" target="all" >
    </ant>
    <ant dir="java" antfile="resolver.xml" target="all" >
    </ant>
  </target>

  <target name="dist"
          description="Create simple distribution of all subprojects">
    <mkdir dir="${dist.dir}/${dist.basename}"/>
    <mkdir dir="${dist.dir}/${dist.basename}/java"/>
        
    <!-- Copy all sources and their corresponding built files -->
    <copy todir="${dist.dir}/${dist.basename}/java">
      <!-- Assumption! Each subproject creates built files within itself -->
      <fileset dir="java/"/>
    </copy>  

    <!-- Copy pertinent top-level files -->
    <copy todir="${dist.dir}/${dist.basename}">
      <fileset dir="." includes="KEYS,LICENSE,NOTICE,README.txt,build.xml"/>
    </copy>

    <tar tarfile="${dist.dir}/${dist.basename}.tar" >
      <tarfileset dir="${dist.dir}">
        <include name="${dist.basename}/"/>
      </tarfileset>
    </tar>

    <gzip zipfile="${dist.dir}/${dist.basename}.tar.gz" src="${dist.dir}/${dist.basename}.tar"/>
    <delete file="${dist.dir}/${dist.basename}.tar" />
    <zip zipfile="${dist.dir}/${dist.basename}.zip" >
      <zipfileset dir="${dist.dir}">
        <include name="${dist.basename}/"/>
      </zipfileset>
    </zip>
  </target>

  <target name="clean"
          description="Cleanup all files in ${dist.dir} and subprojects">
    <delete dir="${dist.dir}"/>
    <ant dir="java/external" antfile="build.xml" target="clean" >
    </ant>
    <ant dir="java" antfile="which.xml" target="clean" >
    </ant>
    <ant dir="java" antfile="resolver.xml" target="clean" >
    </ant>
  </target>

  <target name="javadocs">
    <!-- copy the various javadocs into the website docs -->
    <copy todir="${site.dir}/components/apidocs">
      <fileset dir="java/build/apidocs"/>
    </copy>  
  </target>
</project>
