<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="commons-dir"       value="commons"/>
  <property name="commons-dir.src"   value="${commons-dir}/src"/>
  <property name="commons-dir.build" value="${commons-dir}/build"/>
  <property name="commons-jar"       value="${commons-dir.build}/commons.jar"/>
  
  <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@"/>
  
  <target name="clean">
    <delete dir="${commons-dir.build}"/>
    <delete dir="${tools-dir.build}"/>
    <delete dir="${api-dir.build}"/>
    <delete dir="${impl-dir.build}"/>
  </target>

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

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

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

  <target name="compile.tools" depends="jar.commons">
    <mkdir dir="${tools-dir.build}"/>
    <javac
      srcdir="${tools-dir.src}"
      destdir="${tools-dir.build}"
      debug="true"
      debuglevel="lines,vars,source">
      <classpath>
        <pathelement location="${commons-jar}"/>
      </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="${commons-jar}"/>
        <pathelement location="${tools-jar}"/>
        <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.commons" depends="compile.commons">
    <jar
      basedir="${commons-dir.build}"
      destfile="${commons-jar}"/>
  </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
      file="${api-dir.src}/javax/faces/LogStrings.properties"
      tofile="${api-dir.build}/javax/faces/LogStrings.properties"/>
    <jar
      basedir="${api-dir.build}"
      destfile="${api-jar}"/>
  </target>

  <target name="jar.impl" depends="compile.impl">
    <unzip
      src="${impl-overlay-jar}"
      dest="${impl-dir.build}"/>
<!--    <copy todir="${impl-dir.build}">
      <fileset dir="${impl-dir}/../commons/build"/>
    </copy> -->
    <jar
      basedir="${impl-dir.build}"
      destfile="${impl-jar}"
      excludes="**/*.java"/>
  </target>
  
</project>

<!--
You'll have to touch it up a bit, but this should point you in the right
direction

##
#!/bin/bash

WORKDIR=work

LIBD=<bla-bla-path-to-your-source-files-bla-bla>/lib
SOURCE0=$LIBD/glassfish-jsf-1.2_08.tar.gz
SOURCE1=$LIBD/glassfish-jsf-1.2_08-mojarra-sources.zip
SOURCE2=$LIBD/glassfish-jsf-1.2_08-commons-sources.tar.gz
SOURCE3=$LIBD/glassfish-jsf-1.2_08-build.xml
SOURCE4=$LIBD/glassfish-jsf-1.2_08-impl-overlay.jar

rm -rf $WORKDIR
mkdir  $WORKDIR
pushd  $WORKDIR


#prep
# Unroll all of the sources into a nice-ish directory structure for the
# ant build file to work on.
mkdir -p together/{api,impl,tools,commons}/src

tar -xzvf $SOURCE0
unzip -o jsf-api-1.2_08-sources.jar
mv javax together/api/src
unzip -o jsf-impl-1.2_08-sources.jar
mv com javax together/impl/src

unzip -o $SOURCE1
mv mojarra-1.2_08-b06-FCS-sources/jsf-tools/src/com together/tools/src

# While unrolling the commons code, we're renamespacing it to imitate Sun's
# (unforgivable) behaviour
mkdir -p together/commons/src/com/sun/org/apache/commons
tar -xzvf $SOURCE2
tar -xzvf commons-beanutils-1.7.0-src.tar.gz
mv commons-beanutils-1.7.0-src/src/java/org/apache/commons/beanutils together/commons/src/com/sun/org/apache/commons
tar -xzvf commons-collections-3.1-src.tar.gz
mv commons-collections-3.1/src/java/org/apache/commons/collections together/commons/src/com/sun/org/apache/commons
tar -xzvf commons-digester-1.7-src.tar.gz
mv commons-digester-1.7-src/src/java/org/apache/commons/digester together/commons/src/com/sun/org/apache/commons
tar -xzvf commons-logging-1.0.4-src.tar.gz
mv commons-logging-1.0.4-src/src/java/org/apache/commons/logging together/commons/src/com/sun/org/apache/commons

# Stealing this from the classpathx-mail spec file
perl -p -i -e 's/org(.)apache(.)commons/com${1}sun${1}org${1}apache${1}commons/' `grep org.apache.commons -lr together/commons/src/com/sun`

# Get a copy of the build.xml and inject a bunch of properties
pushd together
  cp $SOURCE3 ./build.xml

  sed -i "s|@COMMONS-PATH@|`build-classpath log4j`:`build-classpath avalon-logkit`:`build-classpath avalon-framework`|g" build.xml  
  sed -i "s|@BASE-DIR@|`pwd`|g;" build.xml
  sed -i "s|@IMPL-OVERLAY@|$SOURCE4|g;" build.xml
  rm -f impl/src/com/sun/faces/vendor/{GlassFish,Jetty6}InjectionProvider.java

  ant jar

popd
-->
