<project name="Servlet Project" default="help" basedir=".">

	<property name="client.home" value="Client"/>
	<property name="server.home" value="Server"/>

	<property name="client.src.home" value="${client.home}/src/"/>
	<property name="server.src.home" value="${server.home}/src/"/>

	<property name="client.bin.home" value="${client.home}/bin"/>
	<property name="server.bin.home" value="${server.home}/bin"/>

	<property name="doc.home" value="doc"/>
	
	<property name="xmlrpc.home" value="xmlrpc-1.1"/>
	<property name="xmlrpc.jar" value="${xmlrpc.home}/xmlrpc-1.1.jar"/>

	<property name="compile.debug" value="true"/>
	<property name="compile.deprecation" value="false"/>
	<property name="compile.optimize" value="true"/>
	
	<!-- ==================== Compilation Classpath =========================== -->
	<!--

	  Rather than relying on the CLASSPATH environment variable, Ant includes
	  features that makes it easy to dynamically construct the classpath you
	  need for each compilation.  The example below constructs the compile
	  classpath to include the servlet.jar file, as well as the other components
	  that Tomcat makes available to web applications automatically, plus anything
	  that you explicitly added.

	-->
	<path id="compile.classpath">
		<!-- Include all JAR files  -->
	    	<pathelement location="${xmlrpc.jar}"/>
	</path>
	
	
	<!-- ==================== Clean Target ==================================== -->
	<!--

	  The "clean" target deletes any previous "build" and "dist" directory,
	  so that you can be ensured the application can be built from scratch.

	-->
	<target name="clean" description="Delete old build and dist directories">
		<delete dir="${client.bin.home}"/>
		<delete dir="${server.bin.home}"/>
	</target>
	
	<!-- ==================== Compile Targets ================================== -->
	<!--

	  The "compile" target transforms source files (from your "src" directory)
	  into object files in the appropriate location in the build directory.

	-->
	<target name="CompileClient" description="Compile Client Java sources">
		<!-- Compile Java classes as necessary -->
		<javac srcdir="${client.src.home}" debug="${compile.debug}" deprecation="${compile.deprecation}" 
			destdir="${client.bin.home}/" optimize="${compile.optimize}">
			<classpath refid="compile.classpath"/>
		</javac>
	</target>

	<target name="CompileServer" description="Compile Server Java sources">
		<!-- Compile Java classes as necessary -->
		<javac srcdir="${server.src.home}" debug="${compile.debug}" deprecation="${compile.deprecation}" 
			destdir="${server.bin.home}/" optimize="${compile.optimize}">
			<classpath refid="compile.classpath"/>
		</javac>				
	</target>


	<!-- ==================== Javadoc Target ================================== -->
	<!--

	  The "javadoc" target creates Javadoc API documentation for the Java
	  classes included in your application.  Normally, this is only required
	  when preparing a distribution release, but is available as a separate
	  target in case the developer wants to create Javadocs independently.

	-->
	<target name="JavadocClient" description="Create Client Javadoc API documentation">
		<javadoc sourcefiles="${client.src.home}/*.java" sourcepath="${client.src.home}" destdir="${doc.home}/api" packagenames="*">
			<classpath refid="compile.classpath"/>
		</javadoc>
	</target>

	<target name="JavadocServer" description="Create Server Javadoc API documentation">
		<javadoc sourcefiles="${server.src.home}/*.java" sourcepath="${server.src.home}" destdir="${doc.home}/api" packagenames="*">
			<classpath refid="compile.classpath"/>
		</javadoc>
	</target>

	<!-- ==================== Run Targets ================================== -->
	<!--

	  The "StartClient" und "StartServer" target starts server and client.

	-->
	<target name="StartClient" description="Start Client">
		<java classname="apachexmlrpc.HelloWorldClient" fork="true">
		<arg line="localhost 9090 set 3456"/> <!-- host port get/set value //-->
			<classpath>
				<pathelement path="${client.bin.home}"/>
				<pathelement location="${xmlrpc.jar}"/>
			</classpath>
		</java>
	</target>

	<target name="StartServer" description="Start Server">
		<java classname="apachexmlrpc.HelloWorldServer"  fork="true">
		<arg line="9090"/>	<!-- port //-->
			<classpath>
				<pathelement path="${server.bin.home}"/>
				<pathelement location="${xmlrpc.jar}"/>
			</classpath>
		</java>		
	</target>

	<!-- ==================== Run all ================================== -->
	<!-- 	The "ClientServer" target starts server and client. -->
	<!-- 	Server und Client parallel starten . fork generiert eine eigne JVM (besser) //-->

	<target name="ClientServer" depends="CompileClient, CompileServer" description="Start Server und Client">
	 <parallel>
		<java classname="apachexmlrpc.HelloWorldServer"  fork="true">
			<arg line="9090"/>	<!-- port //-->
			<classpath>
				<pathelement path="${server.bin.home}"/>
				<pathelement location="${xmlrpc.jar}"/>
			</classpath>
		</java>		


		<java classname="apachexmlrpc.HelloWorldClient" fork="true">
			<arg line="localhost 9090 set 3456"/> <!-- host port get/set value : ignoriert //-->
			<classpath>
				<pathelement path="${client.bin.home}"/>
				<pathelement location="${xmlrpc.jar}"/>
			</classpath>
		</java>
	</parallel>
	</target>

	<!-- ==================== help ================================== -->
	
	<target name="help">
		<echo message="rufen Sie ant -projecthelp   auf"/>
	</target>
</project>

