<project name="Struts-EL" default="compile.library" basedir=".">
 <!--

 Main build.xml for building "Struts-EL", which is a collection of tag
 libraries derived from the Struts tag libraries, such that attribute values
 are evaluated using the expression language evaluator in JSTL 1.0.

 This build.xml will build:
 - core Struts-EL library
 - documentation
 - Struts-EL web applications
 - run unit tests

 This script will delegate some of its work to sub-build.xml files.

 -->
 <!-- ========== Prerequisite Properties =================================== -->

 <!--

 These properties MUST be set on the "ant" command line, a "build.properties"
 file in the base directory, or a "build.properties" file in your user home
 directory.

        jdbc20ext.jar                 (required).  The path to the JAR file
                                      for the JDBC 2.0 Optional Package APIs.

        servlet.jar                   (required).  The path to the Servlet API
                                      classes to compile against (currently,
                                      either version 2.2 or 2.3 supported).

        struts.jar                    The path to the base Struts jar file.

        struts-el.jar                 The path to the base Struts-EL jar file.

        jstl.jar                      The path to the JSTL 1.0 jar file.

        jstl-standard.jar             The path to the JSTL 1.0 "standard" jar
                                      file.

        jstl.tld.dir                  The path to the directory containing the
                                      TLD files for JSTL 1.0.

        commons-beanutils.jar         The path to the JAR file of the Jakarta
                                      Commons BeanUtils package (version 1.0
                                      or later).
 -->

 <!--
     Location of other Struts subprojects

     These default values assume that the checked out locations are the same
     as the full repository paths, and that you are building the trunk.
 -->
 <property name="struts.core.home" value="../.."/>

 <!-- Load local and user build preferences -->
 <property file="build.properties"/>
 <property file="../../build.properties"/>
 <property file="../../../build.properties"/>
 <property file="${user.home}/build.properties"/>

 <!-- Default values for unspecified properties -->
 <property name="jdbc20ext.jar" value="../jdbc2_0-stdext.jar"/>
 <property name="struts.jar" value="${struts.core.home}/dist/lib/struts.jar"/>
 <property name="struts-el.jar"
           value="dist/lib/struts-el.jar"/>


 <!-- ========== Initialization Properties ================================= -->

 <!--
 These property values may optionally be overridden with property settings from
 an "ant" command line, the "build.properties" file in this directory, the
 "build.properties" file in your home directory, or from settings in a superior
 build.xml script.
 -->

 <!-- Output directory name for all files generated by the build process -->
<!-- <property name="build.home" value="${basedir}/contrib/struts-el/target"/> -->
 <property name="build.home" value="${basedir}/target"/>

 <!-- Should Java compilations set the debug compiler option? -->
 <property name="compile.debug" value="true" />

 <!-- Should Java compilations set the deprecation compiler option? -->
 <property name="compile.deprecation" value="true" />

 <!-- Should Java compilations set the optimize compiler option? -->
 <property name="compile.optimize" value="true" />

 <!-- Name of the core struts library -->
 <property name="app.name" value="struts-el"/>

 <!-- Name of the project -->
 <property name="project.name" value="jakarta-struts-el"/>

 <!-- Version of the project -->
 <property name="project.version" value="1.2.9"/>

 <!-- ========== Derived Properties ======================================== -->

 <!--
 These property values are derived from values defined above, and generally
 should NOT be overridden by command line settings
 -->

 <!-- The base directory for distribution targets -->
 <property name="dist.home" value="dist" />

 <!-- The base directory for release targets -->
 <property name="release.home" value="release" />

 <!-- Source directory -->
 <property name="src.dir" value="src"/>

 <!-- Source directory for core struts library -->
 <property name="src.share.dir" value="${src.dir}/share"/>

 <!-- Source directory for non-Cactus unit tests -->
 <property name="src.test.dir" value="${src.dir}/test"/>

 <!-- Directory where core struts library configurations files are stored -->
 <property name="conf.share.dir" value="conf/share"/>

 <!-- Directory where test configurations files are stored -->
 <property name="conf.test.dir" value="conf/test"/>

 <!-- Directory where binary release files are staged -->
 <property name="stage.bin.dir" value="${release.home}/stage/bin"/>

 <!-- Directory where library release files are staged -->
 <property name="stage.lib.dir" value="${release.home}/stage/lib"/>

 <!-- Directory where source release files are staged -->
 <property name="stage.src.dir" value="${release.home}/stage/src"/>

 <!-- Directory where release builds are prepared for upload -->
 <property name="upload.dir" value="${release.home}/upload"/>

 <!-- Base file name for upload files -->
 <property name="upload.file.base" value="${project.name}-${project.version}"/>

 <!-- Doc directory -->
 <property name="doc.dir" value="doc"/>

 <!-- Web directory -->
 <property name="web.dir" value="web"/>

 <!-- This is only used if you execute "ant download-dependencies" -->
 <property name="libdir" value="${basedir}/../../lib" />

 <path id="downloaded.lib.classpath">
   <fileset dir="${libdir}">
     <include name="*.jar"/>
   </fileset>
 </path>

 <property name="jstl.jar"               value="${libdir}/jstl-1.0.6.jar"/>
 <property name="jstl-standard.jar"      value="${libdir}/standard-1.0.6.jar"/>
 <property name="servlet.jar"            value="${libdir}/servlet.jar"/>



 <!-- Compilation Classpath -->
 <path id="compile.classpath">
  <pathelement location="${commons-beanutils.jar}"/>
  <pathelement location="${commons-collections.jar}"/>
  <pathelement location="${commons-digester.jar}"/>
  <pathelement location="${commons-logging.jar}"/>
  <pathelement location="${commons-validator.jar}"/>
  <pathelement location="${jdbc20ext.jar}"/>
  <pathelement location="${servlet.jar}"/>
  <pathelement location="${struts.jar}"/>
  <pathelement location="${struts-el.jar}"/>
  <pathelement location="${jstl.jar}"/>
  <pathelement location="${jstl-standard.jar}"/>


 </path>

 <!-- ========== Executable Targets ======================================== -->

 <!--
 The "init" target evaluates "available" expressions as necessary to modify the
 behavior of this script and print some information on screen
 -->

 <target name="init">
  <echo message="--------- ${project.name} ${project.version} ---------"/>
  <echo message=""/>

  <echo message="java.class.path = ${java.class.path}"/>
  <echo message="java.home = ${java.home}"/>
  <echo message="user.home = ${user.home}"/>
  <echo message="struts.jar = ${struts.jar}"/>
  <echo message="struts-el.jar = ${struts-el.jar}"/>

  <filter  token="version" value="${project.version}"/>

  <tstamp>
      <format property="year" pattern="yyyy"/>
  </tstamp>
 </target>

 <!-- 
 Create directories and copy files for the struts-el library
 -->

 <target name="prepare.library" depends="init">
  <mkdir dir="${build.home}/library/classes/META-INF"/>
  <mkdir dir="${build.home}/library/classes/META-INF/tlds"/>
  <copy file="${struts.jar}" tofile="${build.home}/library/struts.jar"/>
  <copy file="${jstl.jar}" tofile="${build.home}/library/jstl.jar"/>
  <copy file="${jstl-standard.jar}"
        tofile="${build.home}/library/standard.jar"/>
  <copy  todir="${build.home}/conf" filtering="on">
    <fileset dir="${conf.share.dir}" includes="*.MF"/>
  </copy>
<!-- Compile-time dependency only
  <copy file="${jdbc20ext.jar}"
        tofile="${build.home}/library/jdbc2_0-stdext.jar"/>
-->

  <!-- Extract JSTL tlds -->
  <unjar src="${jstl-standard.jar}" dest="${build.home}/library">
      <patternset>
          <include name="**/c*.tld"/>
          <include name="**/f*.tld"/>
          <include name="**/sql*.tld"/>
          <include name="**/x*.tld"/>
      </patternset>
  </unjar>

  <!-- Copy all tlds -->
  <copy todir="${build.home}/library">
   <fileset dir="${build.home}/library/META-INF" includes="*.tld"/>
   <fileset dir="${struts.core.home}/dist/lib" includes="*.tld"/>
  </copy>

  <!-- Remove JSLT META-INF directory -->
  <delete dir="${build.home}/library/META-INF"/>
 </target>

<!-- 
        Prepare static directories for web applications
-->
    <target name="static.webapps">
        <ant antfile="build-webapps.xml" target="static"/>
    </target>

<!--
        Compile code for web applications
-->
    <target name="compile.webapps" depends="compile.library,static.webapps"
     description="Compile Struts web applications">
        <ant antfile="build-webapps.xml" target="compile" />
    </target>

<!--
        Construct distributable web applications
-->
    <target name="dist.webapps" depends="compile.webapps">
        <ant antfile="build-webapps.xml" target="dist"/>
    </target>

 <!--
 Compile struts-el library directory components
 -->
 <target name="compile.library" depends="prepare.library"
         description="Compile Struts-EL library files">
  <javac srcdir="${src.share.dir}" destdir="${build.home}/library/classes"
         debug="${compile.debug}" optimize="${compile.optimize}"
         deprecation="${compile.deprecation}">
   <classpath refid="compile.classpath"/>
  </javac>
  <copy todir="${build.home}/library">
   <fileset dir="${conf.share.dir}" includes="*.tld"/>
   <fileset dir="${conf.share.dir}" includes="*.xml"/>
  </copy>
  <style basedir="${doc.dir}/userGuide" destdir="${build.home}/library"
         extension=".tld" style="${doc.dir}/stylesheets/tld.xsl"
         includes="struts-*.xml"/>
  <copy todir="${build.home}/library/classes/META-INF/tlds">
   <fileset dir="${build.home}/library" includes="struts-*-el.tld"/>
  </copy>
  <copy todir="${build.home}/library/classes/META-INF/tlds" overwrite="true">
      <fileset dir="${build.home}/library" includes="struts-*-el.tld"/>
      <mapper type="regexp" from="^(.*)\.tld$$" to="\1-1.1.tld"/>
  </copy>
  <replace dir="${build.home}/library/classes/META-INF/tlds" >
      <include name="*-1.1.tld"/>
      <replacefilter token="http://struts.apache.org/tags" 
                     value="http://jakarta.apache.org/struts/tags"/>
  </replace>
  <jar jarfile="${build.home}/library/${app.name}.jar"
       manifest="${build.home}/conf/MANIFEST.MF"
       basedir="${build.home}/library/classes" includes="**"/>
 </target>

 <!--
 Create Javadoc documentation
 -->
 <target name="compile.javadoc" description="Generate JavaDoc API docs">
  <delete dir="${build.home}/documentation/api"/>
  <mkdir dir="${build.home}/documentation/api"/>
  <javadoc sourcepath="${src.share.dir}"
           destdir="${build.home}/documentation/api"
           classpath="${servlet.jar}:${jdbc20ext.jar}:${struts.jar}:${jstl.jar}:${jstl-standard.jar}"
           packagenames="org.apache.strutsel.*" author="true" private="true"
           use="true"
           version="true"
           windowtitle="Apache Struts-EL API Documentation"
           doctitle="&lt;h1&gt;Apache Struts-EL Framework (Version ${project.version})&lt;/h1&gt;"
           bottom="Copyright &#169; 2000-${year} - The Apache Software Foundation">
           <classpath refid="compile.classpath"/>
  </javadoc>
 </target>

 <!--
 Create directories and copy files for distribution
 -->
 <target name="prepare.dist" depends="init">
  <mkdir dir="${dist.home}"/>
  <mkdir dir="${dist.home}/lib"/>
  <mkdir dir="${dist.home}/webapps"/>
 </target>

 <!--
 Construct library distributables
 -->

 <target name="dist.library" depends="prepare.dist,compile.library">
  <copy todir="${dist.home}/lib">
	<fileset dir="${build.home}/library" includes="*.jar"/>
	<fileset dir="${build.home}/library" includes="*.tld"/>
	<fileset dir="${build.home}/library" includes="*.xml"/>
  </copy>
 </target>

 <!--
 Copy sources for distribution
 -->
 <target name="dist.source" depends="prepare.dist">
  <copy file="README.txt" tofile="${dist.home}/README.txt"/>
 </target>

 <!--
 Construct complete binary distribution
 -->
 <target name="dist" depends="dist.library,dist.webapps,dist.source"
         description="Construct binary distribution"/>

 <!--
 Construct complete release distributions
 -->
 <target name="release" depends="clean,dist"
         description="Construct release distribution">
  <mkdir dir="${stage.bin.dir}/${upload.file.base}"/>
  <mkdir dir="${stage.lib.dir}/${upload.file.base}-lib"/>
  <mkdir dir="${stage.src.dir}/${upload.file.base}-src"/>
  <copy todir="${stage.bin.dir}/${upload.file.base}">
   <fileset dir="${dist.home}"/>
  </copy>
  <copy todir="${stage.lib.dir}/${upload.file.base}-lib">
	<fileset dir="${dist.home}/lib"/>
  </copy>
  <copy todir="${stage.src.dir}/${upload.file.base}-src">
   <fileset dir=".">
	 <exclude name="build.properties"/>
	 <exclude name="target/**"/>
	 <exclude name="dist/**"/>
	 <exclude name="release/**"/>
	</fileset>
  </copy>
  <mkdir dir="${upload.dir}"/>
  <zip zipfile="${upload.dir}/${upload.file.base}.zip"
		 basedir="${stage.bin.dir}"/>
  <zip zipfile="${upload.dir}/${upload.file.base}-lib.zip"
		 basedir="${stage.lib.dir}"/>
  <zip zipfile="${upload.dir}/${upload.file.base}-src.zip"
		 basedir="${stage.src.dir}"/>
  <tar tarfile="${upload.dir}/${upload.file.base}.tar"
		 basedir="${stage.bin.dir}"
		 longfile="gnu"/>
  <tar tarfile="${upload.dir}/${upload.file.base}-lib.tar"
		 basedir="${stage.lib.dir}"
		 longfile="gnu"/>
  <tar tarfile="${upload.dir}/${upload.file.base}-src.tar"
		 basedir="${stage.src.dir}"
		 longfile="gnu"/>
  <gzip src="${upload.dir}/${upload.file.base}.tar"
		  zipfile="${upload.dir}/${upload.file.base}.tar.gz"/>
  <gzip src="${upload.dir}/${upload.file.base}-lib.tar"
		  zipfile="${upload.dir}/${upload.file.base}-lib.tar.gz"/>
  <gzip src="${upload.dir}/${upload.file.base}-src.tar"
		  zipfile="${upload.dir}/${upload.file.base}-src.tar.gz"/>
 </target>

 <!--
 Clean up build and distribution directories
 -->
 <target name="clean"
         description="Clean build and distribution directories">
  <delete dir="${build.home}"/>
  <delete dir="${dist.home}"/>
  <delete dir="${release.home}"/>
 </target>

 <!--
 All-in-one build target
 -->
 <target name="all" depends="clean,compile.library,compile.webapps"
         description="Clean and build library and web applications"/>

<!--
        Compile Website documenation
-->

<target name="clean.website" depends="clean,compile.website"/>
<target name="compile.website" 
        description="Compile main website">
    <!-- Create the taglib documentation -->
    <style   basedir="${doc.dir}" destdir="${build.home}/documentation"
           extension=".html" style="stylesheets/struts.xsl" includes="*.xml"/>
    <!-- Create the proposals -->
    <style   basedir="${doc.dir}/proposals"
             destdir="${build.home}/documentation/proposals"
           extension=".html" style="../stylesheets/proposals.xsl"
            includes="*.xml"/>
    <!-- Create the user guide -->
    <style   basedir="${doc.dir}/userGuide"
             destdir="${build.home}/documentation/userGuide"
           extension=".html" style="../stylesheets/userGuide.xsl"
            includes="*.xml"/>
    <!-- Copy the basic documentation files -->
    <copy      todir="${build.home}/documentation">
      <fileset   dir="${doc.dir}">
        <include name="**/*.css"/>
        <include name="**/*.gif"/>
        <include name="**/*.html"/>
        <include name="**/*.jpg"/>
        <include name="**/*.js"/>
      </fileset>
    </copy>
    <!-- Copy the basic user guide files -->
    <copy      todir="${build.home}/documentation/userGuide">
      <fileset   dir="${doc.dir}/userGuide">
        <include name="**/*.css"/>
        <include name="**/*.gif"/>
        <include name="**/*.html"/>
        <include name="**/*.jpg"/>
        <include name="**/*.js"/>
      </fileset>
    </copy>
    <!-- Copy the proposal files -->
    <copy      todir="${build.home}/documentation/proposals">
      <fileset   dir="${doc.dir}/proposals">
        <include name="**/*.css"/>
        <include name="**/*.gif"/>
        <include name="**/*.html"/>
        <include name="**/*.jpg"/>
        <include name="**/*.js"/>
      </fileset>
    </copy>
    <!-- Copy the basic user guide files -->
    <copy      todir="${build.home}/documentation/userGuide">
      <fileset   dir="${doc.dir}/userGuide">
        <include name="**/*.css"/>
        <include name="**/*.gif"/>
        <include name="**/*.html"/>
        <include name="**/*.jpg"/>
        <include name="**/*.js"/>
      </fileset>
    </copy>
</target>

<!--
        Run tests on all servers not commented out in the build.properties file.
-->

    <!-- =================== Cactus-Based Tests on Tomcat ================= -->


    <target name="test.tomcat.all"
         depends="skip.tomcat.32,test.tomcat.32,
                  skip.tomcat.40,test.tomcat.40,
                  skip.tomcat.41,test.tomcat.41"
     description="Run Cactus-based unit tests on all servlet engines">
    </target>


    <target name="skip.tomcat.32" unless="tomcat.home.32">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.32' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.32" if="tomcat.home.32"
         depends="skip.tomcat.32,compile.library"
     description="Run Cactus-based unit tests on Tomcat 3.2">
        <echo message="tomcat.home.32 = ${tomcat.home.32}"/>
        <ant antfile="build-tests.xml" target="test.tomcat.32"/>
    </target>


    <target name="skip.tomcat.40" unless="tomcat.home.40">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.40' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.40" if="tomcat.home.40"
         depends="skip.tomcat.40,compile.library"
     description="Run Cactus-based unit tests on Tomcat 4.0">
        <echo message="tomcat.home.40 = ${tomcat.home.40}"/>        
        <ant antfile="build-tests.xml" target="test.tomcat.40"/>
    </target>


    <target name="skip.tomcat.41" unless="tomcat.home.41">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.41' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.41" if="tomcat.home.41"
         depends="skip.tomcat.41,compile.library"
     description="Run unit tests on Tomcat 4.1">
        <echo message="tomcat.home.41 = ${tomcat.home.41}"/>        
        <ant antfile="build-tests.xml" target="test.tomcat.41"/>
    </target>


    <!-- ========== Non-Cactus Unit Tests ================================= -->

    <target name="test.junit" depends="compile.library"
     description="Run non-Cactus JUnit tests">
      <ant antfile="build-tests.xml" target="test.junit"/>
    </target>

</project>

