Source

quartz / webapp / build.xml

<?xml version="1.0"?>
<project name="quartz-web-app" default="main" basedir=".">
    <path id="project.class.path" description="Configure java.class.path">

        <pathelement path="${basedir}" />
        <fileset dir="${basedir}/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${basedir}/lib_build">
            <include name="**/*.jar" />
        </fileset>      

        <pathelement path="${java.class.path}" />
    </path>

    <target name="init" description="properties initialization">

	<property file="${basedir}/build.properties"/>
        <property name="name"	value="${name}" />    
        <property name="build.dir" value="${basedir}/build" />
        <property name="config.dir" value="${basedir}/config" />
        <property name="resources.dir" value="${config.dir}/resources" />
        <property name="dist.dir" value="${basedir}/dist" />
        <property name="doc.dir" value="${basedir}/doc" />
	
        <property name="lib.dir" value="${basedir}/lib" />

        <property name="script.dir" value="${basedir}/script" />
        <property name="src.dir" value="${basedir}/src" />
	<property name="tests.report.dir" value="${basedir}/reports"/>
        <property name="web.dir" value="${basedir}/webroot" />

	    <property name="tests.dir" value="${build.dir}/tests"/>
	    <!--property name="config.tests"             		value="${config.dir}/tests"/-->
	    <property name="tests.report.dir" value="${basedir}/reports"/>	    


        <property name="webinf.build.dir" value="${build.dir}/WEB-INF" />      
        <property name="lib.web.build.dir" value="${build.dir}/WEB-INF/lib" />      
	    <property name="classes.web.build.dir" value="${build.dir}/WEB-INF/classes" />      

        <property name="web.war.file" value="${dist.dir}/${name}.war"/>
        <property name="lib.jar.file" value="${dist.dir}/${name}-lib.jar"/>        


        <property name="log4j.jar.path"					value="${basedir}/lib/log4j.jar" />
	    <property name="debug" 							value="on" />
	    <property name="build.compiler" 				value="modern" />
    	
	    <echo message="properties init"/>      
	</target>

	<target name="clean" depends="init" description="Clean up">
    	<!--<delete dir="${build.dir}"  includeEmptyDirs="true" />
     	<delete dir="${dist.dir}" includeEmptyDirs="true" />    	
     	<delete dir="${tests.report.dir}" includeEmptyDirs="true" /> 
	<delete  defaultexcludes="no">
	
	<fileset dir="${src.dir}" casesensitive="yes">
		<patternset id="non.test.sources">
			<include name="**/Cvs/*"/>
		</patternset>
	</fileset>
	</delete>-->
	<echo message="${src.dir}"/>
		<delete>
		<fileset defaultexcludes="no"  dir="${src.dir}">
			<include name="**/CVS/*"/>
			<include name="**/CVS"/>
		</fileset>
		</delete>
   	</target>   

	<target name="prepare" 
				depends="clean" 
				description="create tree dir">

		<mkdir dir="${build.dir}" />
		<mkdir dir="${dist.dir}" />
		<mkdir dir="${doc.dir}" />


		<mkdir dir="${tests.report.dir}" />


		<mkdir dir="${build.dir}" />

		<mkdir dir="${build.dir}/WEB-INF" />
		<mkdir dir="${build.dir}/WEB-INF/classes" />
		<mkdir dir="${build.dir}/WEB-INF/lib" />      
		<!-- uncomment when there's some junit tests done-->
		<!-- mkdir dir="${tests.dir}" /-->


		<!-- mkdir dir="${tests.report.dir}/html"/> 
		<mkdir dir="${tests.report.dir}" />
		<mkdir dir="${tests.report.dir}/html"/--> 		
		
		<echo message="create dirs"/>
	</target>


   <target name="compile" 
   			   depends="prepare"
   			   description="compile source">

      	<javac srcdir="${src.dir}"
             		destdir="${classes.web.build.dir}"
             		debug="${debug}"
             		includes="**/*.*" >
         	<classpath refid="project.class.path" />
	</javac>

		<!-- copy src resources that sit allong with classes-->
	<copy todir="${classes.web.build.dir}">
		<fileset dir="${src.dir}" includes="**/*.xml"></fileset>
		<fileset dir="${src.dir}" includes="**/*.properties"></fileset>
	</copy>


        <echo message="compiled classes"/>

   </target>
<target name="build-preparation" depends="compile">
 <copy todir="${build.dir}">
			<fileset dir="${web.dir}"></fileset>
		</copy>
		
		<!-- put date and version number to web pages-->
		<replace   summary="true" dir="${build.dir}" includes="**/*.jsp" value="${version}" token="#version#"/>
		<tstamp>
    		<format property="time_stamp" pattern="dd/MM/yyyy" locale="pt"/>
  		</tstamp>		
		<replace   summary="true" dir="${build.dir}" includes="**/*.jsp" value="${time_stamp}" token="#builddate#"/>		
		<echo message="version and date inserted"></echo>

		<copy todir="${lib.web.build.dir}">
			<fileset dir="${lib.dir}" includes="*.jar"></fileset>
		</copy>

		<!-- copy xml's to WEB-INF dir-->

		<!-- copy resources-->
		<copy todir="${classes.web.build.dir}">
			<fileset dir="${resources.dir}" includes="*.properties"></fileset>
			<fileset dir="${resources.dir}" includes="*.xml"></fileset>
		</copy>
		
		<!-- copy log4j conf file
		<copy todir="${classes.web.build.dir}">
			<fileset dir="${config.dir}/log4j" includes="*.*"></fileset>
		</copy>		-->
		<!-- copy hibernate xml's files
		<copy todir="${classes.web.build.dir}">
			<fileset dir="${src.dir}" includes="**/*.xml"></fileset>
		</copy>	-->	
		
		</target>

   <target name="web-war" 
   			   depends="build-preparation" 
   			   description="create war file ">             

		<war 
			destfile="${web.war.file}" 
			compress="true" 		
			update="true"
			webxml="${build.dir}/WEB-INF/web.xml"
			>
				<fileset dir="${build.dir}" includes="**/*" />

		</war>
      	<echo message="war file created"/>
	</target>
	

<target name="classes-jar" 
   			   depends="build-preparation" 
   			   description="create jar of source code ">             

   <jar destfile="${dist.dir}/webapp.jar">
    <fileset dir="${classes.web.build.dir}"
             excludes="**/Test.class"     />
  </jar>
      	<echo message="jar file created"/>
	</target>

  


	<target name="prepareDeployTomCat" 
   	 		    depends="web-war"
   			    description="faz o deploy para o tomcat">
      

      <condition property="host" value="localhost">
         <not><isset property="host"/></not>
      </condition>
      <echo message="host:${host}"></echo>
      
	  <property name="tomcat.server"      value="http://${host}:${tomcat.port}"/>	
	  <property name="path"     value="/${name}"/>
	
	  <!-- Configure properties to access the Manager application -->
  	  <property  name="url.app"  value="${tomcat.server}${path}"/>
	  <property name="url"      value="${tomcat.server}/manager"/>
	  <property name="tomcat.username" value="tomcat"/>
	  <property name="password" value="tomcat"/>
	
	  	  <!-- Configure the custom Ant tasks for the Manager application -->
	  <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"/>
	  <taskdef name="install"    classname="org.apache.catalina.ant.InstallTask"/>
	  <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"/>
	  <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"/>  
	  
	<!-- this is to check if app is running, if it's undeploy gives an error-->	  
	  <condition property="app.noar">
		<http url="${url.app}"/>
  	  </condition>
		<echo message="URL:${url.app}"/>	  

    
  </target>

	<target name="undeployTomCat" depends="prepareDeployTomCat" if="app.noar">
		<remove url="${url}" username="${tomcat.username}" password="${tomcat.password}" path="${path}" />
	  <echo message="undeploy ok"/>
	</target>
      
   <target name="deployTomCat" depends="prepareDeployTomCat,undeployTomCat">
	  <install url="${url}" username="${tomcat.username}" password="${tomcat.password}" path="${path}" war="file:///${web.war.file}"/>
		<echo message="deploy ok"/>

	</target>
       

	<target name="compiletests" depends="prepare" description="compile tests classes">

		<!-- Compila classes de teste -->
		<javac srcdir="${src.dir}"
        	       destdir="${tests.dir}"
                   debug="${debug}"
                   includes="**/tests/**/*.java" >
           
			<classpath refid="project.class.path" />

		</javac>
		<echo message="compiled tests classes"/>

	</target>


	<target name="test"  
				depends="compiletests,deployTomCat">
	  	
	<!-- sleep to wait tomcat deploy -->
		<echo message="waiting some seconds to tomcat deploy the war"/>
		<sleep seconds="8"/>
	<junit  printsummary="true" fork="yes">
      	<formatter type="xml" /> 
      	
 		<batchtest  fork="yes" todir="${tests.report.dir}">
			<fileset dir="${tests.dir}">
				<include name="**/Teste*.class" />
			</fileset>
		</batchtest>
		<classpath>    
			<pathelement path="${project.class.path}" />
		    <fileset dir="lib">
		    	<include name="**/*.jar" />
		    	<!-- -->
		    </fileset>  
		    <fileset dir="lib_build">
		    	<include name="**/*.jar" />
		    </fileset>  		      

			<pathelement location="${tests.dir}"/>
		</classpath>      

    </junit>  
    
	<junitreport todir="${tests.report.dir}">
    	<fileset dir="${tests.report.dir}">
    	  <include name="TEST-*.xml"/>
	</fileset>
        <report format="frames" todir="${tests.report.dir}/html" />
    </junitreport> 
   </target>


	<!-- Main -->
   	<target name="main" 
   				depends="web-war" 
   				description="main build target "/>

</project>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.