<?xml version="1.0" encoding="UTF-8"?>
<project name="session" basedir="." default="wsgen">
<property environment="env" />

	<property name="java.home" value="C:\Program Files\Java\jdk1.6.0_11"/>
	<property name= "jaxws.lib.home" value="D:\Book\jaxws-ri\lib"/>
	<property name= "tomcat.home" value="D:\Book\apache-tomcat-7.0.26"/>
	<property name="build.dir" value="build" />
	<property name="jar.dir" value="jar"/>
	<property name="jar.name" value="meteo"/>
	<property name="resources.home" value="${basedir}/resources"/>
	<property name="lib.dir" value="${axis2.home}/lib" />

		
	<path id="class.path">
		<pathelement location="${java.home}/lib/tools.jar"/>
	
	</path>
	
	<path id="jaxws.classpath">
	     <pathelement location="${java.home}/lib/tools.jar"/>
	     <fileset dir="${jaxws.lib.home}">
	            <include name="*.jar"/>
	            <exclude name="j2ee.jar"/>
	     </fileset>	  
	 </path>

	<target name="compile.serveur">
		<delete dir="${jar.dir}" />
		<mkdir dir="${jar.dir}" />
		<mkdir dir="${jar.dir}/classes" />
		<javac debug="on" memoryMaximumSize="256m" 
				memoryInitialSize="256m" fork="true" 		
				destdir="${jar.dir}/classes" 
				srcdir="${basedir}/src">
				<classpath refid="class.path"/>
		</javac>
		<jar destfile="${jar.dir}/${jar.name}.jar">
			<fileset excludes="**/Test.class" dir="${jar.dir}/classes"/>
		</jar>		
	</target>
	<!-- il faut un jar pour wsgen-->
	<path id="wsgen.path" >
		<path refid="class.path"/>
		<pathelement location="${jar.dir}/${jar.name}.jar"/>
	</path>

	<target name="wsgen" >
		<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
		 	<classpath path="jaxws.classpath"/>		    
		</taskdef>

		<mkdir dir="${basedir}/resources"/>
		<mkdir dir="${build.dir}/classes"/>
		<wsgen		   	
		   	destdir="${build.dir}/classes"
		   	sourcedestdir="${basedir}/src"
		   	genwsdl="true"
		   	verbose="true"
		    resourcedestdir="${basedir}/resources"
		   	keep="true"
		    sei="serveur.ServiceMeteo">
		    <classpath refid="wsgen.path"/>
		 </wsgen>
	</target>
<!-- on doit rajouter les classes generees -->
	<target name="compile.wsgen" >
		<delete dir="${build.dir}" />
				<mkdir dir="${build.dir}" />
				<mkdir dir="${build.dir}/classes" />
				<javac debug="on" memoryMaximumSize="256m" 
						memoryInitialSize="256m" fork="true" 		
						destdir="${build.dir}/classes" 
						srcdir="${basedir}/src">
						<classpath refid="class.path"/>
				</javac>
		<copy todir="${build.dir}/classes">
			<fileset dir= "${jar.dir}/classes">
			<include name="*.class"/>
			</fileset>
		</copy>
	</target>
	<target name="annotationProcessing">
		<taskdef name="annotationProcessing"
		        classname="com.sun.tools.ws.ant.AnnotationProcessingTask">
		        <classpath refid="jaxws.classpath"/>
		</taskdef>
		<annotationProcessing
		        destdir="${build.dir}/classes"
		        sourceDestDir="${build.dir}/classes"
		        srcdir="${basedir}/src"
		        includes="*.java"
		        sourcepath="${basedir}/src">
		    <classpath refid="jaxws.classpath"/>
		</annotationProcessing>
	</target>
	<target name="clean">
		<delete dir="${jar.dir}"/>
		<delete dir="${build.dir}"/>
			
	</target>
	
	<target name="xjc">
		<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
		  <classpath>
		    <fileset dir="${jaxws.lib.home}" includes="*.jar" />
		  </classpath>
		</taskdef>
	<xjc	schema="resources/Requete.xsd" 
		destdir="src" package="serveur.xjc"
			/>
		</target>
	<target name="war">
		<war 
			destFile="meteo.war"
			webxml="./WEB-INF/web.xml"
			basedir="${basedir}">
			
			<classes dir="${build.dir}/classes"/> 
			<lib dir="${jaxws.lib.home}"/>	
			<!--<metainf>
				<fileset dir="${basedir}/META-INF" includes="*.xml"/>
			</metainf>-->
		
			
				<fileset dir="${basedir}/WEB-INF" includes="*.xml" excludes="web.xml"/>
				
				
		
			</war>
			</target>
	<target name="deploy">
	<copy file="meteo.war"  todir="${tomcat.home}/webapps"/>
	<delete file="meteo.war"/>
	</target>
</project>