<project name="Uli" default="build" basedir=".">

	<!-- main targets  -->
	<!-- add optional targets to depends list if needed -->
	<target name="build" depends="setProps,init.build,build.woapp,war,ssdd"/>

  <target name="compileAndBuild" depends="setProps,init.build,compile,build.woapp,war,ssdd" />

	<target name="install" depends="setProps,init.install,build.woapp,war,ssdd"/>
	
	<target name="clean" depends="setProps">
	  	<delete dir="dist"/>
	</target>

	<!-- property determination  -->
	<target name="setProps">
		<property file="${user.home}${file.separator}build.properties"/>
		<property file="build.properties"/>
		<property file="${user.home}${file.separator}Library${file.separator}wobuild.properties"/>
		<condition property="wo.properties.check.failed">
			<not>
    			<and>
      				<isset property="wo.wosystemroot"/>
      				<isset property="wo.wolocalroot"/>
    			</and>
    		</not>
  		</condition>
  		<fail message="Could not find ${user.home}${file.separator}Library${file.separator}wobuild.properties." if="wo.properties.check.failed"/>
		<property name="install.dir" value="${wo.wolocalroot}/Library/WebObjects/Applications"/>
	</target>
		
	<!-- basic initializations  -->
	<target name="init.install">
		 <tstamp/>
		<property name="dest.dir" value="${install.dir}"/>
	</target>
	
	<target name="init.build">
	 	<tstamp/>
		<property name="dest.dir" value="dist"/>
	</target>
	
	<!-- woproject tasks -->
	<target name="build.woapp">
	    
	    <taskdef name="woapplication" classname="org.objectstyle.woproject.ant.WOApplication">
    	</taskdef>

		<!-- add webXML="true" to generate a web.xml file -->
		<woapplication name="${project.name}"  stdFrameworks="false"
											 destDir="${dest.dir}"
											 customInfoPListContent="${customInfoPListContent}"
											 principalClass="${principalClass}"
											 webXML="${webXML}"
											 webXML_CustomContent="${webXML_CustomContent}">
   			<classes dir="${classes.dir}">
      			<patternset>
  					<includesfile name="woproject/classes.include.patternset"/> 
					<excludesfile name="woproject/classes.exclude.patternset"/> 
				</patternset>
   			</classes>
   			<wsresources dir=".">
      			<patternset>
  					<includesfile name="woproject/wsresources.include.patternset"/> 
					<excludesfile name="woproject/wsresources.exclude.patternset"/> 
				</patternset>
			</wsresources>
   			<resources dir=".">
      			<patternset>
  					<includesfile name="woproject/resources.include.patternset"/> 
					<excludesfile name="woproject/resources.exclude.patternset"/> 
				</patternset>
       		</resources>
			<!-- package and go example--> 
			<frameworks root="../packageandgo/frameworks" embed="true">
				<include name="*.framework"/>
			</frameworks>
	   		<frameworks root="${wo.wolocalroot}">
	      			<patternset>
	  				<includesfile name="woproject/ant.frameworks.wo.wolocalroot"/> 
				</patternset>
	   		</frameworks>
			<frameworks root="${wo.wosystemroot}">
      				<patternset>
  					<includesfile name="woproject/ant.frameworks.wo.wosystemroot"/> 
				</patternset>
   			</frameworks>
			<frameworks root="${user.home}">
      				<patternset>
  					<includesfile name="woproject/ant.frameworks.user.home"/> 
				</patternset>
   			</frameworks>
			<otherclasspath root="${wo.wosystemroot}">
   				<patternset>
  					<includesfile name="woproject/ant.classpaths.wo.wosystemroot"/> 
				</patternset>
			</otherclasspath>
			<lib dir=".">
				<include name="Add .jar's that should be copied in the woa."/>
				<exclude name="**/*.woa/**"/>
			</lib>
   		</woapplication>
	</target>

	<!-- optional targets -->
	
	<!-- war target--> 
    <!-- To use this target remove the if="${never}" statement and create the LICENSE in your project  
         and create the web.xml file with the woapplication task.--> 
    <target name="war" if="${never}"> 
        <war destfile="${dest.dir}/${project.name}.war" 
            webxml="${dest.dir}/${project.name}.woa/Contents/web.xml"> 
            <fileset dir="${dest.dir}"> 
                <include name="${project.name}.woa/**"/> 
            </fileset> 
            <fileset dir=".."> 
                <include name="LICENSE"/> 
            </fileset> 
            <lib dir="${wo.wosystemroot}/Library/Frameworks/JavaWOJSPServlet.framework/WebServerResources/Java/"> 
                <include name="JavaWOJSPServlet_client.jar"/> 
            </lib> 
            <zipfileset dir="${wo.wosystemroot}/Library/Frameworks/JavaWOJSPServlet.framework/Resources/" prefix="tlds"> 
                <include name="WOtaglib_1_0.tld"/> 
            </zipfileset> 
        </war> 
    </target> 
	
	<!-- ssdd target--> 
    <!-- To use this target remove the if="${never}" statement and create the LICENSE in your project  
         and create the web.xml file with the woapplication task.--> 
    <target name="ssdd" if="${never}">
    	<mkdir dir="${dest.dir}/${project.name}/WEB-INF/tlds"/>
    	<copy todir="${dest.dir}/${project.name}/WEB-INF/">
            <fileset dir="${dest.dir}/${project.name}.woa/Contents/"> 
                <include name="web.xml"/> 
            </fileset> 
        </copy>
    	<copy todir="${dest.dir}/${project.name}/WEB-INF/">
            <fileset dir=".."> 
                <include name="LICENSE"/> 
            </fileset> 
        </copy>
        <copy todir="${dest.dir}/${project.name}/WEB-INF/">
            <fileset dir="${dest.dir}"> 
                <include name="${project.name}.woa/**"/> 
            </fileset> 
        </copy>    	 
    	<copy todir="${dest.dir}/${project.name}/WEB-INF/tlds">
            <fileset dir="${wo.wosystemroot}/Library/Frameworks/JavaWOJSPServlet.framework/Resources/"> 
                <include name="WOtaglib_1_0.tld"/> 
            </fileset> 
        </copy>    	 
     </target> 
   
	<!-- copy strings files -->	
	<target name="copy.strings">
   		 <copy todir="${dest.dir}/${project.name}.woa/Contents/Resources">
       			<fileset dir="." casesensitive="yes">
				<include name="*.strings"/>
        			<include name="**/*.strings"/>
    			</fileset>
         		<mapper type="flatten"/>
     		</copy>
 	</target>

  <target name = "compile" depends = "setProps,init.build" >
    <mkdir dir = "bin"/>
    <javac srcdir = "src" destdir = "bin">
      <classpath>
      	<!-- package and go example--> 
		<fileset dir="../packageandgo/frameworks">
      	   <include name = "**/*.jar"/>
      	</fileset>
      	<fileset dir="${wo.dir.user.home.library.frameworks}" includesfile = "woproject/ant.frameworks.user.home">
      	   <include name = "**/*.jar"/>
      	</fileset>
      	<fileset dir="${wo.wolocalroot}" includesfile = "woproject/ant.frameworks.wo.wolocalroot">
          <include name = "**/*.jar"/>
        </fileset>
        <fileset dir="${wo.wosystemroot}" includesfile = "woproject/ant.frameworks.wo.wosystemroot">
          <include name = "**/*.jar"/>
        </fileset>
      </classpath>
    </javac>
  </target>
</project>