| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| |
| <project name="CloudStack 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.CloudStack 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="unittest.formatter" value="plain" /> |
| <property name="ovm.dir" location="${base.dir}/ovm" /> |
| <property name="usage.dir" location="${base.dir}/usage" /> |
| |
| <!-- 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,clean-awsapi-tomcat"> |
| <delete dir="${tomcat.home}/webapps/client"/> |
| <delete dir="${tomcat.home}/webapps/awsapi" /> |
| <delete dir="${tomcat.home}/webapps7080/awsapi" /> |
| <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" > |
| <ant antfile="${base.dir}/plugins/hypervisors/ovm/build.xml" target="deploy-ovm"/> |
| </target> |
| |
| <target name="deploy-server" depends="deploy-common, deploy-ovm, deploy-awsapi" > |
| <copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/vms" file="${dist.dir}/systemvm.iso" /> |
| </target> |
| |
| <target name="deploy-server-encrypt" depends="deploy-server" > |
| <move file="${server.deploy.to.dir}/conf/db-enc.properties" tofile="${server.deploy.to.dir}/conf/db.properties" overwrite="true"/> |
| <echo file="/etc/cloud/management/key" append="false">password</echo> |
| </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="${deps.dir}/"> |
| <include name="*.jar"/> |
| <exclude name="servlet*.jar"/> |
| <exclude name="axis2*.jar"/> |
| <exclude name="*slf4j*.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 overwrite="true" todir="${server.deploy.to.dir}/conf"> |
| <fileset dir="${usage.dir}/conf/"> |
| <include name="*.in" /> |
| </fileset> |
| <globmapper from="*.in" to="*" /> |
| </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="deploy-cloudstack-db"> |
| <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="${db.scripts.dir}\\deploy-db-dev.sh ${server-setup.file} ${templates.file} ${DBROOTPW}" /> |
| <exec dir="${db.scripts.dir}" executable="bash" failonerror="true"> |
| <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" depends="deploy-cloudstack-db, deploy-awsapi-db"> |
| </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" failonerror="true"> |
| <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"/> |
| <!-- external deps, added for jenkins |
| depends on mysql-connector-java rpm |
| --> |
| <fileset dir="/usr/share/java/" erroronmissingdir="true"> |
| <include name="mysql-connector-java.jar" /> |
| </fileset> |
| <fileset dir="${unittest.jar.dir}"> |
| <include name="*.jar"/> |
| </fileset> |
| <fileset dir="${deps.dir}"> |
| <include name="junit-*.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="${unittest.formatter}"/> |
| <fileset dir="${utils.test.dir}"> |
| <include name="**/*Test.java"/> |
| </fileset> |
| <fileset dir="${server.test.dir}"> |
| <include name="**/*Test.java"/> |
| <exclude name="**/upgrade/*.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"/> |
| <jvmarg value="-Xms1024m"/> |
| <jvmarg value="-Xmx1024m"/> |
| <batchtest todir="${unittest.dir}"> |
| <formatter type="${unittest.formatter}"/> |
| <fileset dir="${utils.test.dir}"> |
| <include name="**/${test}.java"/> |
| </fileset> |
| <fileset dir="${server.test.dir}"> |
| <include name="**/${test}.java"/> |
| <exclude name="**/upgrade/*.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="${unittest.formatter}"/> |
| <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"> |
| <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.vr.file" location="${dist.dir}/client/conf/virtualrouter_commands.properties" /> |
| <property name="commands.niciranvp.file" location="${dist.dir}/client/conf/nicira-nvp_commands.properties" /> |
| |
| <echo message="build-apidocs" /> |
| <exec dir="${apidoc.scripts.dir}" executable="bash" failonerror="true"> |
| <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.vr.file},${commands.niciranvp.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> |