<!--
// $Id: //open/util/resgen/build.xml#17 $
// package org.eigenbase.resgen is an i18n resource generator
// Copyright (C) 2005-2010 The Eigenbase Project
// Copyright (C) 2005-2010 Disruptive Tech
// Copyright (C) 2005-2010 LucidEra, Inc.
// Portions Copyright (C) 2000-2005 Kana Software, Inc. and others.
// All Rights Reserved.
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version approved by The Eigenbase Project.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//  
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-->
<project name="resgen" default="unspecified">
  <property environment="env"/>
  <property name="project.location" location="."/>
  <property name="lib.dir" value="lib"/>
  <property name="src.dir" value="src"/>
  <property name="classes.dir" value="classes"/>
  <property name="doc.dir" value="doc"/>
  <property name="javadoc.dir" value="${doc.dir}/api"/>
  <property name="resgen.jar.file" value="${lib.dir}/eigenbase-resgen.jar"/>
  <property name="xom.jar.file" value="${lib.dir}/eigenbase-xom.jar"/>
  <property name="version" value="1.3.0.13768"/>

  <path id="project.classpath">
    <pathelement location="${classes.dir}"/>
    <pathelement location="${lib.dir}/junit.jar"/>
  </path>

  <path id="project.boot.classpath">
    <path refid="project.classpath"/>
    <pathelement location="${resgen.jar.file}"/>
    <pathelement location="${xom.jar.file}"/>
  </path>

  <taskdef name="xomgen" classname="org.eigenbase.xom.XOMGenTask">
    <classpath refid="project.boot.classpath"/>
  </taskdef>

  <target name="mkdir.classes">
    <mkdir dir="${classes.dir}"/>
  </target>

<!--
  NOTE:  bootjar requires lib/*.jar to be checked out first
  -->
  <target name="cleanBuild" depends="clean, mkdir.classes">
    <antcall target="compile.xom"/>
    <antcall target="compile.resgen"/>
    <antcall target="bootjar"/>
    <antcall target="javadoc"/>
  </target>

  <target name="dist" depends="clean, version, compile.xom, compile.resgen, javadoc">
    <ant antfile="example/build.xml" target="clean" inheritAll="false" />
    <zip destfile="${project.location}/../eigenbase-resgen-${version}.zip"
      basedir="${project.location}/.."
      includes="
resgen/build.xml,
resgen/COPYING,
resgen/README,
resgen/VERSION,
resgen/doc/**/*,
resgen/example/**/*,
resgen/lib/eigenbase-resgen.jar,
resgen/lib/eigenbase-xom.jar,
resgen/misc/**/*,
resgen/src/**/*"
      excludes="
resgen/classes/**,
resgen/example/classes/**,
resgen/**/*~"/>
  </target>

  <target name="version">
    <echo message="eigenbase-resgen ${version}" file="VERSION"/>
  </target>

  <target name="clean">
    <delete includeEmptyDirs="true" quiet="true">
      <fileset dir="${classes.dir}"/>
      <fileset dir="${src.dir}">
        <include name="**/*.dtd"/>
        <include name="org/eigenbase/xom/meta.dtd"/>
        <include name="org/eigenbase/xom/MetaDef.java"/>
        <include name="org/eigenbase/resgen/Resource.dtd"/>
        <include name="org/eigenbase/resgen/ResourceDef.java"/>
      </fileset>
      <fileset dir="${javadoc.dir}"/>
      <fileset dir=".">
        <include name="VERSION"/>
      </fileset>
    </delete>
  </target>

  <target name="compile.xom" depends="mkdir.classes">
    <xomgen
        model="${src.dir}/org/eigenbase/xom/Meta.xml"
        destdir="${src.dir}"
        classname="org.eigenbase.xom.MetaDef"
        dtdname="meta.dtd"/>
    <javac
        srcdir="${src.dir}"
        destdir="${classes.dir}"
        debug="false"
        classpathref="project.boot.classpath"
        source="1.4" target="1.4">
      <include name="org/eigenbase/xom/**/*.java" />
    </javac>
  </target>

  <target name="compile.resgen" depends="mkdir.classes">
    <xomgen
        model="${src.dir}/org/eigenbase/resgen/Resource.xml"
        destdir="${src.dir}"
        classname="org.eigenbase.resgen.ResourceDef"
        dtdname="Resource.dtd"/>
    <javac
        srcdir="${src.dir}"
        destdir="${classes.dir}"
        debug="false"
        classpathref="project.classpath"
        source="1.4" target="1.4">
      <include name="org/eigenbase/resgen/**/*.java" />
    </javac>
  </target>

  <target name="bootjar"
      depends="mkdir.classes"
      description="Builds a jar file of the classes we need in order to run ant; when the new versions have built, we can replace them. Run this target when the bootstrap files have changed so much that you can't bootstrap, and you need to generate a new eigenbase-xom.jar or eigenbase-resource.jar to check in to source control.">
    <mkdir dir="${lib.dir}" />

    <delete file="${xom.jar.file}"/>
    <jar jarfile="${xom.jar.file}">
      <fileset
          dir="${classes.dir}"
          includes="org/eigenbase/xom/**/*.class"/>
      <zipfileset
          dir="."
          includes="
COPYING,
README,
VERSION"/>
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
        <section name="eigenbase">
          <attribute name="Implementation-Title" value="eiegenbase-xom"/>
          <attribute name="Implementation-Version" value="${version}"/>
          <attribute name="Implementation-Vendor" value="Eigenbase"/>
        </section>
      </manifest>
    </jar>

    <delete file="${resgen.jar.file}"/>
    <jar jarfile="${resgen.jar.file}">
      <fileset
          dir="${classes.dir}"
          includes="org/eigenbase/resgen/**/*.class"/>
      <zipfileset
          dir="."
          includes="
COPYING,
README,
VERSION"/>
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
        <section name="eigenbase">
          <attribute name="Implementation-Title" value="eiegenbase-resgen"/>
          <attribute name="Implementation-Version" value="${version}"/>
          <attribute name="Implementation-Vendor" value="Eigenbase"/>
        </section>
      </manifest>
    </jar>
  </target>

  <target name="javadoc" depends="compile.xom, compile.resgen">
    <delete dir="${javadoc.dir}" />
    <mkdir dir="${javadoc.dir}" />
    <javadoc sourcepath="${src.dir}"
        classpathref="project.classpath"
        destdir="${javadoc.dir}"
        footer="&lt;a href=&quot;http://sourceforge.net&quot;&gt;&lt;img src=&quot;http://sourceforge.net/sflogo.php?group_id=127783&#38;type=1&quot; width=&quot;88&quot; height=&quot;31&quot; border=&quot;0&quot; alt=&quot;SourceForge.net_Logo&quot;&gt;&lt;/a&gt;"
        author="true"
        source="1.4"
        access="package"
        additionalparam="-linksource">
      <tag name="pre" description="Pre-condition:"
           scope="constructors,methods"/>
      <tag name="post" description="Post-condition:"
           scope="constructors,methods"/>
      <tag name="testcase" description="Test-case:"
           scope="constructors,methods,types"/>
      <packageset dir="${src.dir}">
        <include name="**"/>
      </packageset>
      <link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
      <link href="http://www.junit.org/junit/javadoc/3.8.1"/>
    </javadoc>
    <copy file="${src.dir}/org/eigenbase/xom/Meta.xml"
        todir="${javadoc.dir}/org/eigenbase/xom"/>
    <copy file="${src.dir}/org/eigenbase/resgen/Resource.xml"
        todir="${javadoc.dir}/org/eigenbase/resgen"/>
  </target>

  <target name="etags">
    <exec dir="${project.location}" executable="find" output="javaFiles">
      <arg line=". -name &quot;*.java&quot; -print"/>
    </exec>
    <exec dir="${project.location}" executable="ctags">
      <arg line="-e"/>
      <arg line="-L javaFiles"/>
    </exec>
    <delete file="${project.location}/javaFiles" quiet="true"/>
  </target>
</project>
