<project name="glassfish-jsf" basedir="@BASE-DIR@" default="jar">

<!-- If you're encountering this file on repository.jboss.org, you'll need to
do a little work before this will run properly. See the end of this file for a
shell script roughly equivalent to the RPM specfile that built this. -->

  <property name="deps-dir"       value="deps"/>
  
  <property name="tools-dir"       value="tools"/>
  <property name="tools-dir.src"   value="${tools-dir}/src"/>
  <property name="tools-dir.build" value="${tools-dir}/build"/>
  <property name="tools-jar"       value="${tools-dir.build}/tools.jar"/>

  <property name="api-dir"       value="api"/>
  <property name="api-dir.src"   value="${api-dir}/src"/>
  <property name="api-dir.build" value="${api-dir}/build"/>
  <property name="api-jar"       value="${api-dir.build}/jsf-api.jar"/>
  
  <property name="impl-dir"       value="impl"/>
  <property name="impl-dir.src"   value="${impl-dir}/src"/>
  <property name="impl-dir.build" value="${impl-dir}/build"/>
  <property name="impl-jar"       value="${impl-dir.build}/jsf-impl.jar"/>

  <property name="impl-overlay-jar" value="@IMPL-OVERLAY@"/>

  <macrodef name="jar-and-manifest">
    <attribute name="destfile"/>
    <attribute name="basedir"/>
    <attribute name="excludes" default=""/>
    <attribute name="includes" default=""/>
    <attribute name="extension-name"/>
    <sequential>
      <jar destfile="@{destfile}"
        basedir="@{basedir}"
        excludes="@{excludes}"
        includes="@{includes}">
        <manifest>
          <attribute name="Specification-Title"
            value="@MF-SPEC-TITLE@"/>
          <attribute name="Specification-Version"
            value="@MF-SPEC-VERSION@"/>
          <attribute name="Implementation-Title"
            value="@MF-IMPL-TITLE@"/>
          <attribute name="Implementation-Version"
            value="@MF-IMPL-VERSION@"/>
          <attribute name="Implementation-Vendor"
            value="Sun Microsystems, Inc."/>
          <attribute name="Implementation-Vendor-Id"
            value="com.sun"/>
          <attribute name="Extension-Name"
            value="@{extension-name}"/>
        </manifest>
      </jar>
    </sequential>
  </macrodef>
  
  <target name="clean">
    <delete dir="${tools-dir.build}"/>
    <delete dir="${api-dir.build}"/>
    <delete dir="${impl-dir.build}"/>
  </target>

  <target name="compile" depends="compile.tools,compile.api,compile.impl"/>

  <target name="jar" depends="compile,jar.api,jar.impl"/>

  <target name="compile.tools">
    <mkdir dir="${tools-dir.build}"/>
    <javac
      srcdir="${tools-dir.src}"
      destdir="${tools-dir.build}"
      debug="true"
      debuglevel="lines,vars,source">
      <classpath>
        <pathelement path="@DEP-PATH@"/>
      </classpath>
    </javac>
  </target>

  <target name="compile.api">
    <mkdir dir="${api-dir.build}"/>
    <javac
      srcdir="${api-dir.src}"
      destdir="${api-dir.build}"
      debug="true"
      debuglevel="lines,vars,source">
      <classpath>
        <fileset dir="/usr/share/java">
          <include name="jbossweb/el-api.jar"/>
          <include name="jspapi6.jar"/>
          <include name="servletapi6.jar"/>
          <include name="glassfish-jstl.jar"/>
        </fileset>
      </classpath>
    </javac>
  </target>

  <target name="compile.impl" depends="jar.tools,jar.api">
    <mkdir dir="${impl-dir.build}"/>
    <javac
      srcdir="${impl-dir.src}"
      destdir="${impl-dir.build}"
      debug="true"
      debuglevel="lines,vars,source">
      <classpath>
        <pathelement location="${api-jar}"/>
        <pathelement location="${tools-jar}"/>
        <pathelement path="@DEP-PATH@"/>
        <fileset dir="/usr/share/java">
          <include name="portlet-1.0-api.jar"/>
          <include name="glassfish-jstl.jar"/>
          <include name="jbossweb/annotations-api.jar"/>
          <include name="jbossweb/el-api.jar"/>
          <include name="jbossweb/jbossweb.jar"/>
          <include name="jspapi6.jar"/>
          <include name="servletapi6.jar"/>
        </fileset>
      </classpath>
    </javac>
  </target>

  <target name="jar.tools" depends="compile.tools">
    <jar
      basedir="${tools-dir.build}"
      destfile="${tools-jar}"/>
  </target>

  <target name="jar.api" depends="compile.api">
    <copy
      todir="${api-dir.build}/javax/faces">
      <fileset dir="${api-dir.src}/javax/faces">
        <include name="Messages*"/>
        <include name="LogStrings.properties"/>
      </fileset>
    </copy>
    <jar-and-manifest
      basedir="${api-dir.build}"
      destfile="${api-jar}"
      extension-name="javax.faces"/>
  </target>

  <target name="jar.impl" depends="compile.impl">
    <unzip
      src="${impl-overlay-jar}"
      dest="${impl-dir.build}"/>
    <jar-and-manifest
      basedir="${impl-dir.build}"
      destfile="${impl-jar}"
      excludes="**/*.java"
      extension-name="com.sun.faces"/>
  </target>
  
</project>
