mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			282 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			XML
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			282 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			XML
		
	
	
		
			Executable File
		
	
	
	
	
| <?xml version="1.0" encoding="UTF-8"?>
 | |
| 
 | |
| <!-- Copyright 2008 Cloud.com, Inc. All Rights Reserved -->
 | |
| 
 | |
| <project name="Cloud.com Developer Targets" basedir=".">
 | |
|   <description>
 | |
|         This is a developer.xml with tools to start and stop tomcat and 
 | |
|         generally developer targets that has nothing to do with compiling.
 | |
|     </description>
 | |
| 
 | |
|   <dirname property="base.dir" file="${ant.file.Cloud.com Developer Targets}/.."/>
 | |
|   <property name="build.dir" location="${base.dir}/build"/>
 | |
|   
 | |
|   <property name="tomcat.home" location="${env.CATALINA_HOME}"/>
 | |
|   <property name="assertion" value="-ea"/>
 | |
| 
 | |
|   <property name="dist.dir" location="${base.dir}/dist"/>
 | |
|   <property name="deploy.work.dir" location="${dist.dir}"/>
 | |
|   <property name="server.deploy.to.dir" location="${tomcat.home}"/>
 | |
|   <property name="unittest.dir" location="${base.dir}/unittest"/>
 | |
|   <property name="unittest.target.dir" location="${unittest.dir}/classes"/>
 | |
|   <property name="unittest.jar.dir" location="${unittest.dir}/jar"/>
 | |
|   
 | |
|   <macrodef name="compile-test">
 | |
|     <attribute name="top.dir" description="Top Directory of the source.  We will add src to this to get the source code."/>
 | |
|     <attribute name="jar.name" description="Name of the jar file"/>
 | |
|     <attribute name="classpath" description="class path to use"/>
 | |
|     <element name="include-files" optional="true"/>
 | |
|     <element name="exclude-files" optional="true"/>
 | |
|     
 | |
|     <sequential>
 | |
|       <mkdir dir="${unittest.target.dir}/@{jar.name}"/>
 | |
|         
 | |
|       <depend srcdir="@{top.dir}/test" destdir="${unittest.target.dir}/@{jar.name}" cache="${dep.cache.dir}" />
 | |
|         
 | |
|       <echo message="Compiling @{top.dir}/test"/>
 | |
|       <javac srcdir="@{top.dir}/test" debug="${debug}" debuglevel="${debuglevel}" deprecation="${deprecation}" destdir="${unittest.target.dir}/@{jar.name}" source="${source.compat.version}" target="${target.compat.version}" includeantruntime="false" compiler="javac1.6">
 | |
|         <compilerarg line="-Xlint:-path"/>
 | |
|         <classpath refid="@{classpath}" />
 | |
|         <exclude-files/>
 | |
|       </javac>
 | |
|       <jar jarfile="${unittest.jar.dir}/@{jar.name}" basedir="${unittest.target.dir}/@{jar.name}" update="true"/>
 | |
|     </sequential>
 | |
|   </macrodef>
 | |
|   
 | |
| 
 | |
|   <target name="clean-edits" description="Delete all the editor backup files in the source tree.">
 | |
|     <delete>
 | |
|       <fileset dir="${base.dir}" includes="**/*~" />
 | |
|     </delete>
 | |
|   </target>
 | |
| 
 | |
|   <target name="run" depends="start-tomcat"/>
 | |
|   <target name="stop" depends="stop-tomcat"/>
 | |
|   <target name="debug" depends="debug-tomcat"/>
 | |
| 
 | |
|   <target name="setup">
 | |
| 	<mkdir dir="${build.dir}/override"/>   
 | |
|     <copy todir="${build.dir}/override">
 | |
| 	  <fileset dir="${build.dir}">
 | |
| 	    <include name="build-cloud.properties"/>
 | |
| 	    <include name="replace.properties"/>
 | |
| 	  </fileset>
 | |
| 	</copy>  
 | |
|     <loadproperties srcfile="${build.dir}/override/replace.properties" resource="propertyresource"/>
 | |
|     <!-- propertyfile file="${build.dir}/override/replace.properties"/ -->
 | |
|   </target>
 | |
|   
 | |
|   <target name="debug-suspend">
 | |
|     <java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
 | |
|       <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
 | |
|       <jvmarg value="-Xdebug"/>
 | |
|       <jvmarg value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>
 | |
|       <jvmarg value="-ea"/>
 | |
|       <jvmarg value="-Xms256m"/>
 | |
|       <jvmarg value="-Xmx384m"/>
 | |
|     </java>
 | |
|   </target>
 | |
| 
 | |
|   <target name="stop-tomcat">
 | |
|     <java dir="${tomcat.home}/bin/" jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
 | |
|       <arg value="stop"/>
 | |
|     </java>
 | |
|   </target>
 | |
| 
 | |
|   <target name="start-tomcat" depends="stop-tomcat">
 | |
|     <echo message="Start Tomcat" />
 | |
|     <java dir="${tomcat.home}/bin/" jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
 | |
|       <jvmarg value="${assertion}"/>
 | |
|       <jvmarg value="-Xms256m"/>
 | |
|       <jvmarg value="-Xmx384m"/>
 | |
|       <jvmarg value="-ea"/>
 | |
|       <arg value="start"/>
 | |
|     </java>
 | |
|   </target>
 | |
| 
 | |
|   <target name="debug-tomcat">
 | |
|     <java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
 | |
|       <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
 | |
|       <jvmarg value="-Xdebug"/>
 | |
|       <jvmarg value="${debug.jvmarg}"/>
 | |
|       <jvmarg value="-ea"/>
 | |
|       <jvmarg value="-Xms256m"/>
 | |
|       <jvmarg value="-Xmx384m"/>
 | |
|     </java>
 | |
|   </target>
 | |
| 
 | |
|   <target name="clean-tomcat" depends="stop-tomcat">
 | |
|     <delete dir="${tomcat.home}/webapps/client"/>
 | |
|     <delete dir="${tomcat.home}/work/Catalina"/>
 | |
|     <delete dir="${tomcat.home}/temp" />
 | |
|     <delete dir="${tomcat.home}/logs" />
 | |
|     <delete quiet="false" >
 | |
|       <fileset dir="${tomcat.home}/conf" >
 | |
|       	<include name="**/component*.xml" />
 | |
|       </fileset>
 | |
|     </delete>
 | |
|   </target>
 | |
| 
 | |
|   <target name="unzip" if="zip.uptodate">
 | |
|     <unzip src="${deploy.work.dir}/client.zip" dest="${deploy.work.dir}/client"/>
 | |
|   </target>
 | |
| 
 | |
|   <target name="unzip-usage" if="usagezip.uptodate">
 | |
|     <unzip src="${deploy.work.dir}/usage.zip" dest="${deploy.work.dir}/usage"/>
 | |
|   </target>
 | |
|     
 | |
|   <target name="deploy-server" depends="deploy-common" >
 | |
|     <copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/vms" file="${dist.dir}/systemvm.iso" />
 | |
|   </target>
 | |
| 
 | |
|   <target name="deploy-common" > 
 | |
|     <condition property="zip.uptodate">
 | |
|       <available file="${deploy.work.dir}/client.zip" type="file"/>
 | |
|     </condition>
 | |
|     <antcall target="unzip" inheritAll="true"/>
 | |
|     <unwar overwrite="true" src="${deploy.work.dir}/client/client.war" dest="${server.deploy.to.dir}/webapps/client"/>
 | |
|     <copy todir="${server.deploy.to.dir}/lib">
 | |
|       <fileset dir="${deploy.work.dir}/client/lib/">
 | |
|         <include name="*.jar"/>
 | |
|       </fileset>
 | |
|     </copy>
 | |
|     <touch file="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts/vm/hypervisor/xenserver/version"/>
 | |
|     <echo file="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts/vm/hypervisor/xenserver/version" append="false" message="${version}.${build.number}"/>
 | |
|     <copy overwrite="true" todir="${server.deploy.to.dir}/conf">
 | |
|       <fileset dir="${deploy.work.dir}/client/conf/">
 | |
|         <include name="**/*"/>
 | |
|       </fileset>
 | |
|     </copy>
 | |
|     <chmod perm="755">
 | |
|       <fileset dir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib">
 | |
|         <include name="**/*"/>
 | |
|       </fileset>
 | |
|     </chmod>
 | |
|     <replace file="${server.deploy.to.dir}/conf/catalina.properties" summary="true">
 | |
|       <replacetoken><![CDATA[shared.loader=
 | |
| ]]></replacetoken>
 | |
|       <replacevalue><![CDATA[shared.loader=${catalina.home},${catalina.home}/conf
 | |
|           ]]></replacevalue>    </replace>
 | |
|   </target>
 | |
| 
 | |
|   <target name="deploy-usage">
 | |
|     <condition property="usagezip.uptodate">
 | |
|       <available file="${deploy.work.dir}/usage.zip" type="file" />
 | |
|     </condition>
 | |
|     <antcall target="unzip-usage" inheritAll="true" />
 | |
|     <copy todir="${server.deploy.to.dir}/bin">
 | |
|       <fileset dir="${deploy.work.dir}/usage/bin/">
 | |
|         <include name="*.sh"/>
 | |
|       </fileset>
 | |
|     </copy>
 | |
|     <copy overwrite="true" todir="${server.deploy.to.dir}/conf">
 | |
|       <fileset dir="${deploy.work.dir}/usage/conf/">
 | |
|         <include name="**/*"/>
 | |
|       </fileset>
 | |
|     </copy>
 | |
|     <copy overwrite="true" todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib">
 | |
|       <fileset dir="${deploy.work.dir}/usage/lib/">
 | |
|         <include name="**/*.jar"/>
 | |
|       </fileset>
 | |
|     </copy>
 | |
|   </target>
 | |
|   
 | |
|   <target name="deploydb">
 | |
|     <condition property="server-setup.file" value="override/server-setup.xml" else="server-setup.xml">
 | |
|       <available file="${setup.db.dir}/override/server-setup.xml" />
 | |
|     </condition>
 | |
| 
 | |
|     <condition property="templates.file" value="override/templates.sql" else="templates.sql" >
 | |
|     	<available file="${setup.db.dir}/override/templates.sql" />
 | |
|     </condition>
 | |
|   	
 | |
|     <echo message="deploydb ${server-setup.file} ${templates.file} ${DBROOTPW}" />
 | |
|     <exec dir="${setup.db.dir}" executable="bash">
 | |
|       <arg value="deploy-db-dev.sh" />
 | |
|       <arg value="${server-setup.file}" />
 | |
|       <arg value="${templates.file}" />
 | |
|       <arg value="${DBROOTPW}" />
 | |
|       <env key="CATALINA_HOME" value="${tomcat.home}"/>
 | |
|     </exec>
 | |
|   </target>
 | |
|   
 | |
|   <path id="test.classpath">
 | |
|     <path refid="deps.classpath" />
 | |
|     <path refid="dist.classpath"/>
 | |
|     <fileset dir="${unittest.jar.dir}">
 | |
|       <include name="*.jar"/>
 | |
|     </fileset>
 | |
|     <fileset dir="${tools.dir}">
 | |
|       <include name="**/junit-4.8.1.jar"/>
 | |
|     </fileset>
 | |
|     <dirset dir="${utils.test.dir}/resources"/>
 | |
|     <dirset dir="${server.test.dir}/resources"/>
 | |
|     <dirset dir="${base.dir}/setup/db"/>
 | |
|   </path>
 | |
|   
 | |
|   <target name="compile-tests" depends="compile-all">
 | |
|     <mkdir dir="${unittest.dir}"/>
 | |
|     <mkdir dir="${unittest.target.dir}"/>
 | |
|     <mkdir dir="${unittest.jar.dir}"/>
 | |
| 
 | |
|     <compile-test jar.name="utils-test.jar" top.dir="${utils.dir}" classpath="test.classpath"/>
 | |
|     <compile-test jar.name="server-test.jar" top.dir="${server.dir}" classpath="test.classpath"/>
 | |
|   </target>
 | |
|   
 | |
|   <target name="unittest" description="Execute unit tests" depends="compile-tests">
 | |
|     <junit fork="true" printsummary="true" showoutput="true" failureproperty="junit.failure">
 | |
|       <!-- N.b. use failureproperty instead of haltonfailure, because if we use
 | |
|            the former, we will get no detailed report about the failure.
 | |
|            If the test fails, the fail element below will still assure that
 | |
|            the Ant run will exit with error status.
 | |
|       -->
 | |
|       <!--bootclasspath refid="test.classpath"/-->
 | |
|       <classpath refid="test.classpath"/>
 | |
|       <jvmarg value="${debug.jvmarg}"/>
 | |
|       <batchtest todir="${unittest.dir}">
 | |
|         <formatter type="plain"/>
 | |
|         <fileset dir="${utils.test.dir}">
 | |
|           <include name="**/*Test.java"/>
 | |
|         </fileset>
 | |
|         <fileset dir="${server.test.dir}">
 | |
|           <include name="**/*Test.java"/>
 | |
|         </fileset>
 | |
|       </batchtest>
 | |
|     </junit>
 | |
|     <junitreport todir="${unittest.dir}">
 | |
|       <fileset dir="${unittest.dir}"/>
 | |
|       <report todir="${unittest.dir}/test-reports"/>
 | |
|     </junitreport>
 | |
|     <fail if="junit.failure" message="Unit test(s) failed.  See reports!"/>
 | |
|   </target>
 | |
|     
 | |
|   <target name="test" description="Execute one unit test" depends="compile-tests">
 | |
|     <junit fork="true" printsummary="true" clonevm="true" failureproperty="junit.failure">
 | |
|       <!-- N.b. use failureproperty instead of haltonfailure, because if we use
 | |
|            the former, we will get no detailed report about the failure.
 | |
|            If the test fails, the fail element below will still assure that
 | |
|            the Ant run will exit with error status.
 | |
|       -->
 | |
|       <bootclasspath refid="test.classpath"/>
 | |
|       <classpath refid="test.classpath"/>
 | |
|       <batchtest todir="${unittest.dir}">
 | |
|         <formatter type="plain"/>
 | |
|         <fileset dir="${utils.test.dir}">
 | |
|           <include name="**/${test}.java"/>
 | |
|         </fileset>
 | |
|         <fileset dir="${server.test.dir}">
 | |
|           <include name="**/${test}.java"/>
 | |
|         </fileset>
 | |
|       </batchtest>
 | |
|     </junit>
 | |
|     <jvmarg value="${debug.jvmarg}"/>
 | |
|     <junitreport todir="${unittest.dir}">
 | |
|       <fileset dir="${unittest.dir}"/>
 | |
|       <report todir="${unittest.dir}/test-reports"/>
 | |
|     </junitreport>
 | |
|     <fail if="junit.failure" message="Unit test(s) failed.  See reports!"/>
 | |
|   </target>
 | |
|   
 | |
| </project>
 | |
| 
 |