cloudstack/build/build-cloud.xml
2012-09-10 17:21:34 -07:00

614 lines
22 KiB
XML
Executable File

<?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="Cloud Stack" default="help" basedir=".">
<description>
Cloud Stack ant build file
</description>
<!--
Test
Always use this variable to refer to the base directory because this
variable is changeable
-->
<dirname property="base.dir" file="${ant.file.Cloud Stack}/.." />
<property name="build.dir" location="${base.dir}/build" />
<!-- Import anything that the user wants to set-->
<!-- Import properties files and environment variables here -->
<property environment="env" />
<condition property="build-cloud.properties.file" value="${build.dir}/override/build-cloud.properties" else="${build.dir}/build-cloud.properties">
<available file="${build.dir}/override/build-cloud.properties" />
</condition>
<condition property="cloud.properties.file" value="${build.dir}/override/cloud.properties" else="${build.dir}/cloud.properties">
<available file="${build.dir}/override/cloud.properties" />
</condition>
<condition property="override.file" value="${build.dir}/override/replace.properties" else="${build.dir}/replace.properties">
<available file="${build.dir}/override/replace.properties" />
</condition>
<echo message="Using build parameters from ${build-cloud.properties.file}" />
<property file="${build-cloud.properties.file}" />
<echo message="Using company info from ${cloud.properties.file}" />
<property file="${cloud.properties.file}" />
<echo message="Using override file from ${override.file}" />
<property file="${override.file}" />
<property file="${base.dir}/build/build.number" />
<import file="${build.dir}/build-common.xml" />
<!-- In case these didn't get defined in the build-cloud.properties -->
<property name="branding.name" value="default" />
<property name="tomcat.home" value="${env.CATALINA_HOME}" />
<property name="deprecation" value="off" />
<property name="target.compat.version" value="1.6" />
<property name="source.compat.version" value="1.6" />
<property name="debug" value="true" />
<property name="debuglevel" value="lines,source"/>
<!-- directories for build and distribution -->
<property name="dist.dir" location="${base.dir}/dist/" />
<property name="target.dir" location="${base.dir}/target" />
<property name="classes.dir" location="${target.dir}/classes" />
<property name="jar.dir" location="${target.dir}/jar" />
<property name="dep.cache.dir" location="${target.dir}/dep-cache" />
<property name="build.log" location="${target.dir}/ant_verbose.txt" />
<property name="deps.dir" location="${base.dir}/deps" />
<property name="xenapi.dir" location="${deps.dir}/XenServerJava" />
<!-- directories for client compilation-->
<property name="client.dir" location="${base.dir}/client" />
<property name="client.test.dir" location="${client.dir}/test" />
<property name="client.target.dir" location="${target.dir}/ui" />
<property name="ui.user.dir" location="${base.dir}/ui" />
<property name="setup.db.dir" location="${base.dir}/setup/db" />
<property name="setup.apidoc.dir" location="${base.dir}/setup/apidoc" />
<!-- directories for server compilation-->
<property name="server.dir" location="${base.dir}/server" />
<property name="server.test.dir" location="${server.dir}/test" />
<property name="server.dist.dir" location="${dist.dir}/client" />
<property name="db.scripts.dir" location="${target.dir}/db"/>
<property name="apidoc.scripts.dir" location="${base.dir}/setup/apidoc/"/>
<!-- directories for core code compilation-->
<property name="core.dir" location="${base.dir}/core" />
<property name="core.test.dir" location="${core.dir}/test/" />
<!-- directories for agent code compilation-->
<property name="agent.dir" location="${base.dir}/agent" />
<property name="agent.test.dir" location="${utils.dir}/test/" />
<property name="agent.dist.dir" location="${dist.dir}/agent" />
<property name="scripts.dir" location="${base.dir}/scripts" />
<property name="scripts.target.dir" location="${target.dir}/scripts"/>
<!-- directories for console proxy compilation-->
<property name="console-proxy.dir" location="${base.dir}/console-proxy" />
<property name="console-proxy.dist.dir" location="${dist.dir}/console-proxy" />
<property name="tools.dir" location="${base.dir}/tools" />
<!-- <property name="antcontrib.dir" location="${tools.dir}/tools/ant/apache-ant-1.8.0/lib" />-->
<property name="deploy.dir" location="${build.dir}/deploy" />
<property name="production.dir" location="${deploy.dir}/production" />
<property name="meld.home" location="/usr/local/bin" />
<property name="assertion" value="-da" />
<!-- directory for vmware-base library -->
<property name="vmware-base.dir" location="${base.dir}/vmware-base" />
<!-- directories for branding -->
<property name="branding.dir" location="${build.dir}/deploy/branding/${branding.name}" />
<property name="core.jar" value="cloud-core.jar" />
<property name="utils.jar" value="cloud-utils.jar" />
<property name="server.jar" value="cloud-server.jar" />
<property name="agent.jar" value="cloud-agent.jar" />
<property name="console-proxy.jar" value="cloud-console-proxy.jar" />
<property name="api.jar" value="cloud-api.jar"/>
<property name="xenapi.jar" value="cloud-xenapi.jar" />
<property name="vmware-base.jar" value="cloud-vmware-base.jar" />
<property name="vmware.jar" value="cloud-vmware.jar" />
<!--
Import information about the build version and company information
-->
<property name="version" value="${company.major.version}.${company.minor.version}.${company.patch.version}" />
<!-- Class paths -->
<path id="prod.src.path">
<pathelement location="${server.dir}/src" />
<pathelement location="${utils.dir}/src" />
<pathelement location="${core.dir}/src" />
<pathelement location="${agent.dir}/src" />
</path>
<path id="src.classpath">
</path>
<path id="compile.deps.classpath">
</path>
<path id="deps.classpath">
<!--filelist files="${deps.classpath}" /-->
<fileset dir="${deps.dir}" erroronmissingdir="false">
<include name="*.jar" />
</fileset>
<path refid="compile.deps.classpath" />
</path>
<path id="dist.classpath">
<fileset dir="${target.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${target.dir}/jar">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.classpath">
<fileset dir="${dist.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- directories for util code compilation-->
<property name="utils.dir" location="${base.dir}/utils" />
<property name="utils.test.dir" location="${utils.dir}/test/" />
<path id="utils.classpath">
<path refid="deps.classpath" />
</path>
<target name="compile-utils" depends="-init" description="Compile the utilities jar that is shared.">
<compile-java jar.name="${utils.jar}" top.dir="${utils.dir}" classpath="utils.classpath" >
<include-files>
<fileset dir="${utils.dir}/certs">
<include name="*.keystore" />
</fileset>
</include-files>
</compile-java>
</target>
<property name="api.dir" location="${base.dir}/api" />
<property name="api.test.dir" location="${api.dir}/test/" />
<path id="api.classpath">
<path refid="deps.classpath" />
<path refid="dist.classpath"/>
</path>
<target name="compile-api" depends="-init, compile-utils" description="Compile the utilities jar that is shared.">
<compile-java jar.name="${api.jar}" top.dir="${api.dir}" classpath="api.classpath" />
</target>
<path id="core.classpath">
<path refid="deps.classpath" />
<path refid="dist.classpath" />
</path>
<target name="compile-core" depends="-init, compile-utils, compile-api" description="Compile the core business logic.">
<compile-java jar.name="${core.jar}" top.dir="${core.dir}" classpath="core.classpath" />
</target>
<path id="vmware-base.classpath">
<path refid="deps.classpath" />
<path refid="dist.classpath" />
</path>
<target name="compile-vmware-base" depends="-init, compile-utils" description="Compile the VMware support library">
<compile-java jar.name="${vmware-base.jar}" top.dir="${vmware-base.dir}" classpath="vmware-base.classpath" />
</target>
<path id="xenapi.classpath">
<path refid="deps.classpath" />
<path refid="dist.classpath" />
</path>
<target name="compile-xenapi" depends="-init" description="Compile XenServer java sdk.">
<compile-java jar.name="${xenapi.jar}" top.dir="${xenapi.dir}" classpath="xenapi.classpath" />
</target>
<path id="server.classpath">
<path refid="deps.classpath" />
<path refid="dist.classpath" />
</path>
<target name="compile-server" depends="-init, compile-utils, compile-xenapi, compile-core, compile-agent" description="Compile the management server.">
<compile-java jar.name="${server.jar}" top.dir="${server.dir}" classpath="server.classpath" />
</target>
<path id="client.classpath">
<path refid="deps.classpath" />
<path refid="dist.classpath" />
</path>
<target name="build-scripts" depends="-init">
<copy todir="${scripts.target.dir}">
<fileset dir="${scripts.dir}">
<include name="**/*"/>
<exclude name="**/fsimage.so"/>
<exclude name="**/ping.tar.bz2"/>
<exclude name="**/vhd-util"/>
<exclude name="**/.*" />
</fileset>
<filterset>
<filter token="VERSION" value="${impl.version}"/>
</filterset>
</copy>
<copy todir="${scripts.target.dir}">
<fileset dir="${scripts.dir}">
<include name="**/fsimage.so"/>
<include name="**/ping.tar.bz2"/>
<include name="**/vhd-util"/>
</fileset>
</copy>
</target>
<target name="build-ui" depends="-init" description="Builds the UI">
<mkdir dir="${client.target.dir}" />
<copy todir="${client.target.dir}">
<fileset dir="${ui.user.dir}">
<include name="**/*.html" />
<include name="**/*.js"/>
<include name="**/*.jsp"/>
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
<filterset>
<filter token="VERSION" value="${impl.version}"/>
</filterset>
</copy>
<copy todir="${client.target.dir}">
<fileset dir="${ui.user.dir}">
<include name="**/*"/>
<exclude name="**/*.html" />
<exclude name="**/*.js"/>
<exclude name="**/*.jsp"/>
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${client.target.dir}">
<fileset dir="${client.dir}/WEB-INF/classes">
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<target name="build-server" depends="compile-server">
<mkdir dir="${server.dist.dir}" />
<mkdir dir="${server.dist.dir}/lib" />
<mkdir dir="${server.dist.dir}/conf" />
<copy todir="${jar.dir}">
<fileset dir="${deps.dir}">
<include name="cloud-*.jar"/>
</fileset>
</copy>
<copy overwrite="true" todir="${server.dist.dir}/conf">
<fileset dir="${base.dir}/client/tomcatconf">
<include name="*.in" />
</fileset>
<globmapper from="*.in" to="*" />
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value="${override.file}" />
</filterreader>
</filterchain>
</copy>
<copy overwrite="true" todir="${server.dist.dir}/conf">
<fileset dir="${server.dir}/src/com/cloud/migration">
<include name="*.xml" />
</fileset>
</copy>
<copy overwrite="true" todir="${db.scripts.dir}">
<fileset dir="${setup.db.dir}">
<include name="**/*"/>
</fileset>
<filterset>
<filter token="VERSION" value="${impl.version}"/>
</filterset>
</copy>
</target>
<path id="console-proxy.classpath">
<path refid="deps.classpath" />
<path refid="dist.classpath" />
</path>
<target name="compile-console-proxy" depends="-init" description="Compile the console proxy.">
<compile-java jar.name="${console-proxy.jar}" top.dir="${console-proxy.dir}" classpath="console-proxy.classpath" >
<include-files>
<fileset dir="${console-proxy.dir}/certs">
<include name="*.keystore" />
<include name="*.crt" />
<include name="*.key" />
</fileset>
</include-files>
</compile-java>
</target>
<target name="copy-console-proxy" depends="-init">
<property name="copyto.dir" value="${console-proxy.dist.dir}" />
<mkdir dir="${copyto.dir}" />
<mkdir dir="${copyto.dir}/conf" />
<mkdir dir="${copyto.dir}/logs" />
<mkdir dir="${copyto.dir}/applet" />
<mkdir dir="${copyto.dir}/images" />
<mkdir dir="${copyto.dir}/js" />
<mkdir dir="${copyto.dir}/ui" />
<mkdir dir="${copyto.dir}/css" />
<mkdir dir="${copyto.dir}/certs" />
<copy todir="${copyto.dir}">
<fileset dir="${deps.dir}">
<include name="log4j-1.2.15.jar" />
<include name="apache-log4j-extras-1.0.jar" />
<include name="gson.jar" />
</fileset>
</copy>
<copy todir="${copyto.dir}">
<fileset dir="${jar.dir}">
<include name="cloud-console-proxy.jar" />
</fileset>
</copy>
<copy todir="${copyto.dir}/conf">
<fileset dir="${production.dir}/consoleproxy/conf">
<include name="log4j-cloud.xml" />
<include name="consoleproxy.properties" />
</fileset>
</copy>
<copy todir="${copyto.dir}/images">
<fileset dir="${console-proxy.dir}/images">
<include name="*.jpg" />
<include name="*.gif" />
<include name="*.png" />
<include name="*.cur" />
</fileset>
</copy>
<copy todir="${copyto.dir}/js">
<fileset dir="${console-proxy.dir}/js">
<include name="*.js" />
</fileset>
</copy>
<copy todir="${copyto.dir}/ui">
<fileset dir="${console-proxy.dir}/ui">
<include name="*.ftl" />
</fileset>
</copy>
<copy todir="${copyto.dir}/css">
<fileset dir="${console-proxy.dir}/css">
<include name="*.css" />
</fileset>
</copy>
<copy todir="${copyto.dir}/certs">
<fileset dir="${console-proxy.dir}/certs">
<include name="*.keystore" />
<include name="*.crt" />
<include name="*.key" />
</fileset>
</copy>
</target>
<target name="build-console-proxy" depends="-init, compile-console-proxy, copy-console-proxy">
<copy todir="${console-proxy.dist.dir}">
<fileset dir="${console-proxy.dir}/scripts">
</fileset>
</copy>
<copy todir="${console-proxy.dist.dir}/conf">
<fileset dir="${console-proxy.dir}/conf">
</fileset>
</copy>
</target>
<path id="agent.classpath">
<path refid="deps.classpath" />
<fileset dir="${target.dir}">
<include name="**/${core.jar}" />
<include name="**/${utils.jar}" />
<include name="**/${api.jar}"/>
</fileset>
</path>
<target name="compile-agent" depends="-init, compile-utils, compile-core, compile-api" description="Compile the management agent.">
<compile-java jar.name="${agent.jar}" top.dir="${agent.dir}" classpath="agent.classpath" />
</target>
<target name="build-agent" depends="-init, compile-agent">
<mkdir dir="${agent.dist.dir}" />
<mkdir dir="${agent.dist.dir}/scripts" />
<mkdir dir="${agent.dist.dir}/conf" />
<mkdir dir="${agent.dist.dir}/logs" />
<mkdir dir="${agent.dist.dir}/db" />
<mkdir dir="${agent.dist.dir}/storagehdpatch" />
<condition property="agent.properties" value="override/agent.properties" else="agent.properties">
<available file="${agent.dir}/conf/override/agent.properties" />
</condition>
<condition property="developer.properties" value="override/developer.properties" else="developer.properties">
<available file="${agent.dir}/conf/override/developer.properties" />
</condition>
<copy overwrite="true" todir="${agent.dist.dir}/conf" flatten="true">
<fileset dir="${agent.dir}/conf">
<include name="${agent.properties}" />
<include name="${developer.properties}" />
</fileset>
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value="${override.file}" />
</filterreader>
</filterchain>
</copy>
<copy overwrite="true" todir="${agent.dist.dir}/conf" flatten="true">
<fileset dir="${agent.dir}/conf">
<include name="log4j-cloud.xml.in" />
</fileset>
<globmapper from="*.in" to="*" />
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value="${override.file}" />
</filterreader>
</filterchain>
</copy>
<delete file="${agent.dist.dir}/conf/log4j-cloud.xml.in"/>
<copy todir="${agent.dist.dir}">
<fileset dir="${agent.dir}/scripts">
<include name="agent.sh" />
<include name="run.sh" />
</fileset>
</copy>
</target>
<target name="build-servers" depends="-init, build-server" />
<target name="build-opensource" depends="-init, build-server, build-agent, build-scripts, build-ui, build-console-proxy, package-oss-systemvm-iso">
<copy overwrite="true" todir="${dist.dir}">
<fileset dir="${base.dir}/build/deploy/">
<include name="deploy-agent.sh" />
<include name="deploy-server.sh" />
<include name="deploy-console-proxy.sh" />
<include name="install.sh" />
</fileset>
<fileset dir="${base.dir}/client">
<include name="setup/**/*" />
</fileset>
</copy>
<copy overwrite="true" todir="${jar.dir}">
<fileset dir="${deps.dir}">
<include name="vmware-*.jar" />
</fileset>
</copy>
<chmod file="${dist.dir}/deploy-agent.sh" perm="uog+xr" />
<chmod file="${dist.dir}/deploy-server.sh" perm="uog+xr" />
</target>
<target name="build-systemvm-patch" depends="-init">
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.dir}/build-patch" />
<mkdir dir="${dist.dir}/build-patch/usr/sbin" />
<copy overwrite="true" todir="${dist.dir}/build-patch">
<fileset dir="${base.dir}/patches/systemvm/debian/config/" >
<include name="**/*"/>
</fileset>
<fileset dir="${base.dir}/patches/systemvm/debian/vpn/" >
<include name="**/*"/>
</fileset>
<fileset dir="${base.dir}/patches/systemvm/debian/xe/" >
<include name="**/*"/>
<exclude name="**/xe-*" />
<exclude name="**/xen-*" />
</fileset>
</copy>
<copy overwrite="true" todir="${dist.dir}/build-patch/usr/sbin/">
<fileset dir="${base.dir}/patches/systemvm/debian/xe/" >
<include name="**/xe-*" />
<include name="**/xen-*" />
</fileset>
</copy>
<tar destfile="${dist.dir}/patch.tar">
<tarfileset dir="${dist.dir}/build-patch/" filemode="755">
<include name="**/*"/>
<exclude name="**/.classpath" />
<exclude name="**/.project" />
<exclude name="**/wscript_build" />
</tarfileset>
</tar>
<copy file="${base.dir}/patches/systemvm/debian/config/root/.ssh/authorized_keys" todir="${dist.dir}/"/>
<gzip destfile="${dist.dir}/cloud-scripts.tgz" src="${dist.dir}/patch.tar"/>
<delete file="${dist.dir}/patch.tar"/>
<delete dir="${dist.dir}/build-patch"/>
</target>
<target name="help">
<echo level="info" message="Ant Build File for CloudStack" />
<echo level="info" message="Type 'ant -projecthelp' to get a list of targets and their descriptions." />
</target>
<target name="usage" depends="help" />
<target name="-init">
<mkdir dir="${dist.dir}" />
<mkdir dir="${target.dir}" />
<record name="${build.log}" loglevel="verbose" action="start" />
<!-- create a UTC build timestamp using ISO 8601 formatting -->
<tstamp>
<format property="utc.build.timestamp" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'" timezone="GMT" />
</tstamp>
<!-- remember who/where did the build -->
<exec executable="hostname" outputproperty="host.name" />
<property name="builder.at" value="${user.name} at ${host.name}" />
<property name="builder.id" value="${builder.at}, on ${utc.build.timestamp}" />
<property name="built.by" value="${builder.at}, ${utc.build.timestamp}" />
<echo level="info" message="builder: ${builder.id}" />
<!-- set build.number property, stored in eponymous file -->
<buildnumber file="${build.dir}/build.number" />
<condition property="impl.version" value="${version}.${manual.build.number}" else="${version}.${utc.build.timestamp}">
<isset property="manual.build.number"/>
</condition>
<echo message="Build number is ${impl.version}" />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${jar.dir}" />
<mkdir dir="${docs.dir}" />
<mkdir dir="${dep.cache.dir}" />
<condition property="mvn" value="mvn.bat" else="mvn">
<os family="Windows"/>
</condition>
<!-- Download all dependencies using maven -->
<exec executable="${mvn}" resolveexecutable="true" searchpath="true" failifexecutionfails="false">
<arg value="-P"/>
<arg value="deps"/>
<arg value="-pl"/>
<arg value="deps"/>
</exec>
<record name="${build.log}" action="stop" />
</target>
<target name="clean" description="clean up files generated by the build">
<delete file="${build.log}" />
<delete dir="${classes.dir}" />
<delete dir="${jar.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${unittest.dir}"/>
</target>
<target name="compile-all" description="Compile all of the jars" depends="compile-utils, compile-api, compile-core, compile-server, compile-plugins"/>
<target name="clean-all" depends="clean, clean-plugins, clean-awsapi" description="Clean all of the generated files, including dependency cache and javadoc">
<delete dir="${target.dir}" />
</target>
</project>