<?xml version="1.0" encoding="iso-8859-1"?>
<!--
 The contents of this file are subject to the terms 
 of the Common Development and Distribution License 
 (the "License").  You may not use this file except 
 in compliance with the License.
 
 You can obtain a copy of the license at 
 glassfish/bootstrap/legal/CDDLv1.0.txt or 
 https://glassfish.dev.java.net/public/CDDLv1.0.html. 
 See the License for the specific language governing 
 permissions and limitations under the License.
 
 When distributing Covered Code, include this CDDL 
 HEADER in each file and include the License file at 
 glassfish/bootstrap/legal/CDDLv1.0.txt.  If applicable, 
 add the following below this CDDL HEADER, with the 
 fields enclosed by brackets "[]" replaced with your 
 own identifying information: Portions Copyright [yyyy] 
 [name of copyright owner]
-->

<project name="TopLink Essentials" default="all" basedir=".">  

<!-- ========== Initialize Properties =================================== -->

    <!--
        component.name: required property.  the value should be the
                        name of the component directory
    -->
    <property name="component.name" value="toplink-persistence"/>

    <property file="./build.properties"/>

	<property file="${user.home}/build.properties"/>
    <property file="${basedir}/../bootstrap/project.properties"/>

    <property name="query.antlr.dir"
              location="src/java/oracle/toplink/essentials/internal/parsing/ejbql/antlr273"/>

    <!-- all -->
    <target name="all" depends="compile, assemble"
            description="Build entire component">
    </target>

    <!-- build -->
    <target name="build" depends="compile, assemble"
            description="Build entire component">
    </target>

    <!-- init. Initialization involves creating publishing directories and
         OS specific targets. --> 
    <target name="init" description="${component.name} initialization">
        <tstamp>
            <format property="start.time" pattern="MM/dd/yyyy hh:mm aa"/>
        </tstamp>    
        <echo message="Building component ${component.name}"/>
        <mkdir dir="${component.classes.dir}"/>
    </target>

    <!-- compile --> 
    <target name="compile" depends="init, antlr-generate"
            description="Compile TopLink Essentials sources">  
     
        <javac srcdir="${src.dir}" 
               destdir="${component.classes.dir}"
               debug="${javac.debug}" 
               optimize="${javac.optimize}"
               source="${javac.source}" 
               deprecation="${javac.deprecation}"
               failonerror="true">
            <classpath>
				<pathelement location="${antlr.jar}"/>
				<pathelement location="${asm.jar}"/>
				<pathelement location="${asm-attrs.jar}"/>
				<pathelement location="${javaee.jar}"/>
            </classpath>
            <include name="oracle/toplink/essentials/**"/>          
        </javac>
    </target>
    
    <!-- assemble -->
    <target name="assemble" depends="init"
            description="Create TopLink Essentials jar files">               

        <jar jarfile="${entity-persistence.jar}">
            <fileset dir="${component.classes.dir}">
                <include name="oracle/toplink/essentials/**/*.class"/>
				<exclude name="oracle/toplink/essentials/internal/ejb/cmp3/JavaSECMPInitializerAgent.class"/>
            </fileset>
            <fileset dir="${src.dir}">
                <include name="oracle/toplink/essentials/**/*.properties"/>
            </fileset>
            <fileset dir="./resources">
                <include name="META-INF/services/javax.persistence.spi.PersistenceProvider"/>
            </fileset>
        </jar>                        

        <jar jarfile="${entity-persistence-agent.jar}">
		     <manifest>
                <attribute name="Class-Path" value="toplink-essentials.jar javaee.jar antlr.jar asm.jar asm-attrs.jar" />
				<attribute name="Premain-Class" value="oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializerAgent" />
            </manifest>
            <fileset dir="${component.classes.dir}">
                <include name="oracle/toplink/essentials/internal/ejb/cmp3/JavaSECMPInitializerAgent.class"/>
            </fileset>
        </jar>   
                     
    </target>

    <target name="clean" depends="antlr-clean" description="Clean the build">
        <delete includeEmptyDirs="true" failonerror="false">
            <fileset dir="${component.classes.dir}"/>
        </delete>
    </target>

  
    <!-- javadocs -->
    <target name="docs" depends="init">
        <mkdir dir="${release.javadocs.dir}"/>
<!-- TODO - create javadoc target -->
    </target>

    <!-- Run ANTLR. -->
    <target name="antlr-generate">
        <antlr dir="${query.antlr.dir}" target="${query.antlr.dir}/EJBQLParser.g">
            <classpath path="${antlr.jar}"/>
        </antlr>
    </target>

    <!-- Delete the files generated by ANTLR. -->
    <target name="antlr-clean">
        <delete>
            <fileset dir="${query.antlr.dir}">
                <!-- antlr-generated sources -->
                <include name="EJBQLLexer.java"/>
                <include name="EJBQLParser.java"/>
                <include name="*TokenTypes.java"/>
                <include name="*TokenTypes.txt"/>
            </fileset>
        </delete>
    </target>

</project>


