<project name="SOA Sample Client" default="All" basedir=".">
  <description>
     Build file to build SOA Tests.
  </description>
    
    <echo message=" ===========================================================" />
    <echo message=" ================== SOA Hello Teamcenter ===================" />
    <echo message=" ===========================================================" />
   

    <!--Javac target version-->
    <property name="src"                     location="${basedir}/src"/>  
    <property name="soa.home"                location="../../.."/>  


        
    <fileset dir="${soa.home}/java/libs" id="soa.libs">
        <include name="TcSoaCommon_*.jar" />
        <include name="TcSoaClient_*.jar" />
        <include name="TcSoaStrongModel_*.jar" />
        <include name="TcSoaCoreStrong_*.jar" />
        <include name="TcSoaCoreTypes_*.jar" />
        <include name="TcSoaQueryStrong_*.jar" />
        <include name="TcSoaQueryTypes_*.jar" />
        <include name="commons-httpclient-3.1.jar" />
     </fileset>

        
    <fileset dir="${soa.home}/java/libs" id="third.party.libs">
        <include name="log4j.jar" />
        <include name="commons-logging.jar" />
        <include name="commons-codec.jar" />
        <include name="teamcenter_sso_applib.jar"/>
        <include name="teamcenter_sso_common.jar"/>
        <include name="teamcenter_sso_webtoolkit.jar"/>
        <include name="avalon-framework-4.1.5.jar" />
        <include name="jacorb.jar" />
        <include name="resolver.jar" />
        <include name="xercesImpl.jar" />
        <include name="xml-apis.jar" />
        <include name="logkit-1.2.jar" />
        <include name="fscclient.jar"/>
        <include name="fccclient.jar"/>
        <include name="tcserverjavabinding.jar"/>
        <include name="tcmemjavabinding.jar"/>
        <include name="tcgatewaystubs.jar"/>
    </fileset>

    <condition property="is.windows">
        <os family="windows"/>
    </condition>
    
    <condition property="is.unix"> 
        <os family="unix"/>
    </condition>

    <path id="build.classpath">
        <fileset refid="soa.libs"  />
    </path>

    <path id="run.classpath">
        <pathelement location="${basedir}/bin"/>
        <fileset refid="soa.libs"  />
        <fileset refid="third.party.libs"  />
    </path>

    <target name="init">
        <tstamp/>
        <mkdir dir="${basedir}/bin"/> 
    </target>

    <target name="clean"  >
        <delete  dir="${basedir}/bin" />   
    </target>
 
    <target name="Compile" depends="init" description="compile the source">
        
         <javac destdir="${basedir}/bin" debug="true" srcdir="${src}">
            <classpath refid="build.classpath"/>     
         </javac>
         <copy todir="${basedir}/bin" file="${src}/log4j.properties" />

    </target>
    
    <target name="CreateWindowsScript" depends="Compile" if="is.windows">             

        <property name="app.cp" refid="run.classpath" />
        
        <echo file="RunMe.bat" append="false" >
            @echo off
        
            if ""%1""==""-h""    goto Help
            if ""%1""==""-help"" goto Help
            if ""%1""==""?""     goto Help
                                    
            SET APP_CP=${app.cp}
                                    
        
            "${java.home}\bin\java" -cp %APP_CP% -Dhost=%1% com.teamcenter.hello.Hello 
        
            goto Exit
        
            :Help
            echo Usage: RunMe [http://server:port/tc]
            echo        Will default to http://localhost:7001/tc if no argument is given.
        
            :Exit

        </echo>
    </target>
        
    <target name="CreateUnixScript" depends="Compile" if="is.unix">
                        
        <property name="app.cp" refid="run.classpath" />

                        
        <echo file="RunMe.sh" append="false" >
         
            if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "?" ]|| [ $# -ne 1 ] 
            then
                echo "Usage: ./RunMe.sh [http://server:port/tc]"
                echo "Will default to http://localhost:7001/tc if no argument is given."
            else
                                
                export APP_CP=${app.cp}
                "${java.home}/bin/java" -cp $APP_CP -Dhost=$1 com.teamcenter.hello.Hello 
            fi
        
        </echo>
        <chmod file="RunMe.sh" perm="ugo+rx"/>
    </target>

            
    <target name="All" depends="init,Compile,CreateWindowsScript,CreateUnixScript"/>
    
</project>
