<!--
  ~ 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="googlespellcheck" basedir="." default="run.client">
	
	<property name="wsdl" value="http://tools.wso2.net:12001/axis2/services/SimplifiedSpellCheck?wsdl" />
	
	<property name="dest.dir" value="build" />
	
	<property name="dest.dir.classes" value="${dest.dir}/classes" />
	
	<property name="dest.dir.lib" value="${dest.dir}/lib" />
	
	<property name="axis2.home" value="../../" />
	
	<path id="client.class.path">
		<fileset dir="${axis2.home}/lib">
			<include name="*.jar" />
		</fileset>
		<fileset dir="${dest.dir.lib}" includes="*.jar" />
	</path>
	
	<path id="build.class.path">
		<fileset dir="${axis2.home}/lib">
			<include name="*.jar" />
		</fileset>
	</path>
	
	<target name="clean">
		
		<delete dir="${dest.dir}" />
		
		<delete dir="src" includes="sample/spellcheck/stub/**"/>
	
	</target>
	
	<target name="prepare">
		
		<mkdir dir="${dest.dir}" />
		
		<mkdir dir="${dest.dir.classes}" />
		
		<mkdir dir="${dest.dir.lib}" />
	
	</target>
	
	<target name="run.client" depends="clean,prepare">
	
		<antcall target="client.codegen-stub">
			<param name="wsdl" value="${wsdl}"/>
		</antcall>
		
		<antcall target="client.compile" />
		
		<antcall target="client.jar" />
		
		<antcall target="client.run" />	
	</target>
	
	<target name="client.codegen-stub">
	
		<java classname="org.apache.axis2.wsdl.WSDL2Java">
			<arg value="-uri" />
			<arg value="${wsdl}" />
			<arg value="-p" />
			<arg value="sample.spellcheck.stub" />
			<arg value="-o" />
			<arg value="src" />
			<arg value="-f"/>
			<classpath refid="build.class.path" />
		</java>
	
	</target>
	
	<target name="client.compile">
		
		<javac srcdir="src" destdir="${dest.dir.classes}">
			<classpath refid="build.class.path" />
		</javac>
	
	</target>
	
	<target name="client.jar">
		
		<jar basedir="${dest.dir.classes}" destfile="${dest.dir.lib}/editor.jar" />
	
	</target>
	
	<target name="client.run">
	
		<java classname="sample.spellcheck.editor.SuggestionForm" fork="true">
			<classpath refid="client.class.path" />
		</java>
		
	</target>

</project>