cloudstack/build/developer.xml
Ewan Mellor 22119a33b5 Added build-apidocs-zip build target that generates HTML versions of the
API docs.  Uses XML/XSLT generation system originally by Abhinandan Prateek
(I think).  CSS updates from Jessica Tomechak.  gen_toc.py and build script
changes by me.
2012-02-08 20:40:29 -08:00

405 lines
16 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"/>
<property name="ovm.dir" location="${base.dir}/ovm" />
<property name="ovm-scripts.dir" location="${ovm.dir}/scripts" />
<!-- directories for api doc -->
<property name="api.docs.dir" location="${dist.dir}/apidocs" />
<condition property="jmxport" value="${jmxport.override}" else="45219">
<isset property="jmxport.override" />
</condition>
<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="-Dcom.sun.management.jmxremote.port=${jmxport}"/>
<jvmarg value="-Dcom.sun.management.jmxremote.authenticate=false"/>
<jvmarg value="-Dcom.sun.management.jmxremote.ssl=false"/>
<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="-Dcom.sun.management.jmxremote.port=${jmxport}"/>
<jvmarg value="-Dcom.sun.management.jmxremote.authenticate=false"/>
<jvmarg value="-Dcom.sun.management.jmxremote.ssl=false"/>
<jvmarg value="-Xms256m"/>
<jvmarg value="-Xmx512m"/>
<jvmarg value="-XX:MaxPermSize=128m"/>
<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="-Dcom.sun.management.jmxremote.port=${jmxport}"/>
<jvmarg value="-Dcom.sun.management.jmxremote.authenticate=false"/>
<jvmarg value="-Dcom.sun.management.jmxremote.ssl=false"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="${debug.jvmarg}"/>
<jvmarg value="-ea"/>
<jvmarg value="-Xms256m"/>
<jvmarg value="-Xmx512m"/>
<jvmarg value="-XX:MaxPermSize=128m"/>
</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-ovm" >
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts">
<fileset dir="${ovm-scripts.dir}">
<include name="**/*"/>
</fileset>
</copy>
</target>
<target name="deploy-server" depends="deploy-common, deploy-ovm" >
<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>
<copy overwrite="true" todir="${server.deploy.to.dir}/lib" file="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/cloud-mysql-connector-java-5.1.7-bin.jar" />
<delete file="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/cloud-mysql-connector-java-5.1.7-bin.jar" />
<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="${db.scripts.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>
<chmod perm="666">
<fileset dir="${db.scripts.dir}">
<include name="**/*"/>
</fileset>
</chmod>
</target>
<target name="deploydb-simulator">
<condition property="server-setup.file" value="${setup.db.dir}/override/server-setup.xml" else="server-setup.xml">
<available file="${setup.db.dir}/override/server-setup.xml" />
</condition>
<condition property="templates.file" value="${setup.db.dir}/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="${db.scripts.dir}" executable="bash">
<arg value="deploy-db-simulator.sh" />
<arg value="${server-setup.file}" />
<arg value="${templates.file}" />
<arg value="${DBROOTPW}" />
<env key="CATALINA_HOME" value="${tomcat.home}"/>
</exec>
<chmod perm="666">
<fileset dir="${db.scripts.dir}">
<include name="**/*"/>
</fileset>
</chmod>
</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" 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.
-->
<classpath refid="test.classpath"/>
<jvmarg value="${debug.jvmarg}"/>
<jvmarg value="-ea"/>
<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-suspend" description="Execute one unit test" 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.
-->
<classpath refid="test.classpath"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>
<jvmarg value="${assertion}"/>
<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="build-apidocs" description="Generate api documentation" depends="build-all-with-simulator">
<property name="commands.file" location="${dist.dir}/client/conf/commands.properties" />
<property name="commands.ext.file" location="${dist.dir}/client/conf/commands-ext.properties" />
<property name="commands.f5.file" location="${dist.dir}/client/conf/f5bigip_commands.properties" />
<property name="commands.juniper.file" location="${dist.dir}/client/conf/junipersrx_commands.properties" />
<property name="commands.netscaler.file" location="${dist.dir}/client/conf/netscalerloadbalancer_commands.properties" />
<property name="commands.vr.file" location="${dist.dir}/client/conf/virtualrouter_commands.properties" />
<echo message="build-apidocs" />
<exec dir="${apidoc.scripts.dir}" executable="bash">
<arg value="build-apidoc.sh" />
<arg value="${target.dir}/jar" />
<arg value="${deps.dir}" />
<arg value="${dist.dir}" />
<arg value="-f ${commands.file},${commands.ext.file},${commands.f5.file},${commands.juniper.file},${commands.netscaler.file},${commands.vr.file}" />
</exec>
<echo message="Result locates at ${dist.dir}/commands.xml" />
<chmod perm="666">
<fileset dir="${apidoc.scripts.dir}">
<include name="**/*"/>
</fileset>
</chmod>
</target>
<target name="build-apidocs-zip" depends="build-apidocs">
<delete file="${dist.dir}/apidocs-${version}.zip" />
<zip destfile="${dist.dir}/apidocs-${version}.zip" basedir="${dist.dir}/xmldoc/html" />
</target>
</project>