<?xml version="1.0"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements. See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership. The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License. You may obtain a copy of the License at
 
  http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied. See the License for the
  specific language governing permissions and limitations
  under the License.
-->

<project name="Inbound Connection Demo" default="build" basedir=".">
    <property environment="env"/>

    <property environment="env"/>
    <condition property="cxf.home" value="${env.CXF_HOME}">
        <isset property="env.CXF_HOME"/>
    </condition>

    <fail message="this sample need to use CXF_HOME enviroment, please setup CXF_HOME in your environment" unless="cxf.home"/>

    <property name="j2ee.resources.dir" location="${basedir}/../common/resources"/>
    <property name="build.archives" value="${basedir}/j2ee-archives"/>
    <property name="ejb.xml" location="./etc/ejb.xml"/>
    <property name="j2ee.archives" value="j2ee-archives"/>
    <property name="demos.current.dir" value="."/>
    <property name="build.classes.dir" value="${basedir}/build"/>

    <import file="../../../common_build.xml"/>


    <path id="other.classpath">
        <fileset dir="${cxf.home}/modules/integration" >
            <include name="cxf-integration-jca-*.jar"/>
        </fileset>
        <pathelement location="${basedir}/../common/lib/geronimo-ejb_3.0_spec-1.0.1.jar"/>
    </path>

    <target name="init">
        <mkdir dir="${build.classes.dir}/cxf-rar/META-INF"/>
        <mkdir dir="${build.classes.dir}/lib"/>
        <mkdir dir="${j2ee.archives}"/>
    </target>

    <target name="generate.rar" depends="init">
        <copy file="${basedir}/etc/ra.xml" todir="${build.classes.dir}/cxf-rar/META-INF"/>
        <copy todir="${build.classes.dir}/cxf-rar">
            <fileset dir="${cxf.home}/lib">
                <include name="*.jar"/>
                <exclude name="cxf*.jar"/>
            </fileset>
            <fileset dir="${cxf.home}/modules">
                <include name="*.jar"/>
                <exclude name="*manifest*.jar"/>
            </fileset>
            <fileset dir="${cxf.home}/modules/integration">
                <include name="*.jar"/>
                <exclude name="*-jbi-*.jar"/>
            </fileset>
        </copy>
        <jar destfile="${build.classes.dir}/lib/cxf.rar"
         basedir="${build.classes.dir}/cxf-rar"/>
    </target>

    <target name="build" description="compile the code" depends="init,j2ee.compile,build.ejb.jar"/>

    <target name="j2ee.compile">
        <javac srcdir="${basedir}/src" destdir="${build.classes.dir}" debug="true" fork="yes">
            <include name="**/*.java"/>
            <classpath>
                <pathelement location="${cxf.home}/modules/cxf-manifest.jar"/>
                <pathelement location="${build.classes.dir}"/>
                <path refid="cxf.classpath"/>
                <path refid="other.classpath"/>
            </classpath>
        </javac>
    </target>

    <target name="clean">
        <delete dir="${build.dir}"/>
        <delete dir="${basedir}/j2ee-archives"/>
    </target>

    <target name="build.ejb.jar">
        <jar destfile="${j2ee.archives}/dispatchedgreeterejb.jar">
            <metainf dir="./etc">
                <include name="*ejb*.xml"/>
            </metainf>
            <fileset dir="${build.classes.dir}/" includes="org/**/*.class"/>
            <fileset dir="${build.classes.dir}">
                <include name="**/ejb/*.class"/>
            </fileset>
        </jar>
    </target>

    <target name="client" description="run the client side demo " >
        <java classname="demo.client.GreeterClient" fork="true">
            <sysproperty key="java.util.logging.config.file" value="${cxf.home}/etc/logging.properties"/>
            <arg value="${wsdl.location}"/>
            <classpath>
                <pathelement location="${build.classes.dir}"/>
                <path refid="cxf.classpath"/>
            </classpath>
        </java>
    </target>
</project>
