build.xml

<?xml version="1.0" encoding="UTF-8"?>

<project name="FaxionBuild" default="debug">

<!-- =================================================================================================== -->

<!-- TASKS -->

<!-- =================================================================================================== -->

<!--

This build uses the "FTP" task, which requires that the commons-net jar be in ant's classpath.

Info:

http://ant.apache.org/manual/install.html#optionalTasks

Download:

http://commons.apache.org/net/download_net.cgi

And the ant-contrib jar

Download:

http://sourceforge.net/projects/ant-contrib/

-->

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

<!--

Our own custom tasks for CDN invalidation and status checking

They require:

level3integration.jar

built by us

commons-codec-1.4.jar

Download:

http://commons.apache.org/codec/download_codec.cgi

-->

<taskdef name="cdninvalidate" classname="com.truegames.level3integration.InvalidateTask"/>

<taskdef name="cdnstatus" classname="com.truegames.level3integration.StatusTask"/>

<!-- =================================================================================================== -->

<!-- PROPERTIES -->

<!-- =================================================================================================== -->

<property environment="env"/>

<property file="../../user.properties"/><!-- Try custom user.properties first-->

<property file="user.properties"/><!--Then use the ones checked into the repository-->

<property file="teamcity.properties"/><!-- defaults and local versions for those values which are actually set on TeamCity -->

<property name="pac.dir" value="../../pac"/>

<!-- =================================================================================================== -->

<!-- BASIC / INTERNAL TARGETS -->

<!-- =================================================================================================== -->

<target name="debug">

<echo message="my.BUILD_NUMBER: ${my.BUILD_NUMBER}"/>

<echoproperties/>

</target>

<target name="init.createTestProductFiles" depends="props.environment.1">

<mkdir dir="${VersionFilesPath}"/>

</target>

<!--

Sequence:

props.pre.environment

props.environment.1

clean

props.environment.2

prepare

init

-->

<target name="init" depends="prepare" unless="init.Complete">

<echo message="running the target: init"/>

<!--check that necessary properties exist -->

<antcall target="failIfPropertyNotFound">

<param name="propertyName" value="url.root"/>

</antcall>

<!--check that necessary local directories/files exist. -->

<antcall target="failIfDirectoryNotFound">

<param name="directoryName" value="${User.BuildArtifacts.dir}"/>

</antcall>

<!--<antcall target="failIfDirectoryNotFound">--> <!-- todo Doesn't work on InitialProduct. Make this smarter. -->

<!--<param name="directoryName" value="${LocalProductPath}"/>-->

<!--</antcall>-->

<propertyfile file="${persisted.build.properties.file}">

<entry key="init.Complete" value="true"/>

</propertyfile>

<property file="${persisted.build.properties.file}"/> <!-- Don't read this file until this point or later. Otherwise, the build initialization gets stopped. -->

<echo message="init.Complete: ${init.Complete}"/>

</target>

<target name="clean" depends="props.environment.1" unless="init.Complete">

<echo message="running the target: clean"/>

</target>

<target name="prepare" depends="props.environment.2" unless="init.Complete">

<echo message="running the target: prepare"/>

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

</target>

<target name="clean.pac.create.product">

<delete dir="${ProductsBaseDir}/Backups/${ProductTitle}" failonerror="false"/>

<move todir="${ProductsBaseDir}/Backups/${ProductTitle}" failonerror="false">

<fileset dir="${LocalProductPath}"/>

</move>

</target>

<!-- =================================================================================================== -->

<!-- HELPER TARGETS -->

<!-- =================================================================================================== -->

<target name="copy.artifacts" depends="init">

<!--fail if the Launcher project is not present-->

<!-- todo this won't work on updates, when the versioned launcher files aren't there. Make it smarter. -->

<!--<fail message="Run the Launcher project first! ${VersionedFilesPath}/Launcher/launcher.ui.exe not found">-->

<!--<condition>-->

<!--<not>-->

<!--<available file="launcher.ui.exe" filepath="${VersionedFilesPath}/Launcher"/>-->

<!--</not>-->

<!--</condition>-->

<!--</fail>-->

<!--get the directories only-->

<!--<copy todir="${versioned.artifacts}" includeEmptyDirs="true" overwrite="true">-->

<!--<fileset id="versioned.files" erroronmissingdir="true" dir="${ArtifactsSource.dir}">-->

<!--<exclude name="**/*.*"/>-->

<!--</fileset>-->

<!--</copy>-->

<!--Copy the versioned source into place-->

<!--todo:figure out reading includes from a file-->

<copy todir="${VersionedFilesPath}/Client" includeEmptyDirs="false" overwrite="true">

<fileset id="versioned.client.files" erroronmissingdir="true" dir="${ArtifactsSource.dir}">

<exclude name="FaxionConfig.ini"/>

<exclude name="launcher/*.*"/>

<exclude name="Repository/*.*"/>

<depth max="0" min="0"/>

</fileset>

</copy>

<copy todir="${VersionedFilesPath}/Repository" includeEmptyDirs="false" overwrite="true">

<fileset id="versioned.repository.files" erroronmissingdir="true" dir="${ArtifactsSource.dir}/Repository"/>

</copy>

<!--convert the versioned fileset to a human-readable format-->

<pathconvert property="readable.versioned.client.fileset" refid="versioned.client.files" pathsep="${line.separator}"/>

<pathconvert property="readable.versioned.repository.fileset" refid="versioned.repository.files" pathsep="${line.separator}"/>

<!--write the values of the versioned files-->

<echo file="${BaseSourcePath}/_lists/versioned.client.txt" message="${readable.versioned.client.fileset}" append="false"/>

<echo file="${BaseSourcePath}/_lists/versioned.repository.txt" message="${readable.versioned.repository.fileset}" append="false"/>

<!--Copy the unversioned source into place-->

<!--todo:figure out reading includes from a file-->

<copy todir="${UnversionedFilesPath}/Client" includeEmptyDirs="false" overwrite="true">

<fileset id="unversioned.client.files" dir="${ArtifactsSource.dir}">

<include name="FaxionConfig.ini"/>

</fileset>

</copy>

<copy todir="${UnversionedFilesPath}/Repository" includeEmptyDirs="false" overwrite="true">

<fileset id="unversioned.repository.files" dir="${ArtifactsSource.dir}/Repository">

<exclude name="**/*.*"/>

</fileset>

</copy>

<!--convert the unversioned fileset to a human-readable format-->

<pathconvert property="readable.unversioned.client.fileset" refid="unversioned.client.files" pathsep="${line.separator}"/>

<pathconvert property="readable.unversioned.repository.fileset" refid="unversioned.repository.files" pathsep="${line.separator}"/>

<!--write the values of the unversioned files-->

<echo file="${BaseSourcePath}/_lists/unversioned.client.txt" message="${readable.unversioned.client.fileset}" append="false"/>

<echo file="${BaseSourcePath}/_lists/unversioned.repository.txt" message="${readable.unversioned.repository.fileset}" append="false"/>

</target>

<target name="help.execute_pac" unless="${debug}">

<!--Run the PatchAssistant on the command file-->

<exec executable="PatchAssistant.Console.exe" failonerror="true">

<arg line="/run ${pac.commandfile}"/>

</exec>

</target>

<!--help.packagelist.build must run first!-->

<target name="help.packagelist.ftp" unless="${debug}">

<!--Perform the ftp operation-->

<ftp server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}"

remotedir="${remotedir}"

binary="no">

<fileset file="${pac.packageList}"/>

</ftp>

</target>

<presetdef name="failIfProd">

<fail message="Should not run this target against prod.">

<condition>

<equals arg1="${deploy.target}" arg2="prod"/>

</condition>

</fail>

</presetdef>

<presetdef name="failIfLocal">

<fail message="Should not run this target against local.">

<condition>

<equals arg1="${deploy.target}" arg2="local"/>

</condition>

</fail>

</presetdef>

<!-- Creates an ftp directory (remotedir) on the specified server.

!!!!!!!! Don't call this preset directly unless you're protected by unless="${debug}" !!!!!!!!

Use help.mkFtpDir.target so that if the 'debug' variable is true, no ftp tasks are executed.

-->

<presetdef name="help.mkFtpDir">

<ftp action="mkdir"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}"

remotedir="${remotedir}"/>

</presetdef>

<!--Creates an ftp directory-->

<target name="help.mkFtpDir.target" unless="${debug}">

<help.mkFtpDir remotedir="${remotedir.antcall}"/>

</target>

<target name="help.upload.installers" depends="init" unless="${debug}">

<help.mkFtpDir remotedir="${installer.deploy.dir}"/>

<ftp server="${cdn.root}"

remotedir="${installer.deploy.dir}"

userid="${cdn.username}"

password="${cdn.password.ant}"

retriesAllowed="2"

binary="yes">

<fileset file="${installerOutput.dir}/${ProductTitle}-${LOCALE}${OutFileSuffix.Full}"/>

<fileset file="${installerOutput.dir}/${ProductTitle}-${LOCALE}${OutFileSuffix.Lite}"/>

</ftp>

</target>

<presetdef name="readPatchProjectForVersionId">

<loadfile property="latestVersionId" srcFile="${LocalProductPath}/${Project}/solid.patchproject">

<filterchain>

<linecontains>

<contains value="Id"/>

</linecontains>

<tailfilter lines="1"/>

<deletecharacters chars="/&gt;&lt; "/>

<replacestring from="Id" to=""/>

<striplinebreaks/>

</filterchain>

</loadfile>

</presetdef>

<presetdef name="readPatchProjectForVersion">

<loadfile>

<filterchain>

<linecontains>

<contains value="Title"/>

</linecontains>

<tailfilter lines="1"/>

<deletecharacters chars="/&gt;&lt; "/>

<replacestring from="Title" to=""/>

<striplinebreaks/>

</filterchain>

</loadfile>

</presetdef>

<!--

Tries to run specified target (use: target="myTarget" attribute) for each project in the project.list property.

NOTE: Some targets specify the "${Project}.isBeingUpdated" condition, so those won't get run if that property is not set

NOTE: inheritall is set to TRUE

-->

<presetdef name="target.foreach.project">

<foreach list="${project.list}" delimiter="," param="Project" inheritall="true"/>

</presetdef>

<!--Verify that directories exist-->

<target name="failIfDirectoryNotFound">

<fail message="Could not find directory: ${directoryName}">

<condition >

<not>

<available filepath="${directoryName}" type="dir" file=""/>

</not>

</condition>

</fail>

</target>

<!--Verify that a property is set-->

<target name="failIfPropertyNotFound">

<fail unless="${propertyName}" message="Property not set: ${propertyName}"/>

</target>

<target name="help.checkPatchProjectFile">

<condition property="solid.patchproject.file.exists">

<available file="${LocalProductPath}/${Project}/solid.patchproject"/>

</condition>

</target>

<target name="help.readPatchProjectForVersion" if="solid.patchproject.file.exists">

<readPatchProjectForVersionId property="latestVersionId" srcFile="${LocalProductPath}/${Project}/solid.patchproject"/>

</target>

<target name="help.setLatestVersionZero" unless="solid.patchproject.file.exists">

<property name="latestVersionId" value="0"/>

</target>

<target name="help.getLatestVersionId" depends="help.checkPatchProjectFile, help.readPatchProjectForVersion, help.setLatestVersionZero"/>

<target name="help.writeVersionFile" depends="help.getLatestVersionId">

<fail unless="latestVersionId"/>

<!--Copy the version xml template-->

<property name="versionfile" value="${VersionFilesPath}/${Project}.version"/>

<copy file="pac/project.version.xml" tofile="${versionfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${versionfile}" token="%Version%" value="${latestVersionId}"/>

<replace file="${versionfile}" token="%Name%" value="${ReleaseTitle}"/>

<!--Make another copy, available as the 'current' version-->

<copy file="${versionfile}" tofile="${CurrentVersionFilesPath}/${Project}.version" overwrite="true"/>

</target>

<!-- Creates/uploads a file describing the versions deployed on Live so far -->

<target name="help.create.Live.versions.file" depends="init,help.makeCDNpackageDirs" unless="${debug}">

<echo message="running the target: help.create.Live.versions.file"/>

<mkdir dir="${LocalProductPath}"/>

<!-- create properties file -->

<property name="live.versions.filepath" value="${VersionFilesPath}/${live.versions.file.name}"/>

<propertyfile file="${live.versions.filepath}">

<!-- On creation, they all have the same version value -->

<entry key="version.Live" value="${ReleaseTitle}"/>

<entry key="version.Repository" value="${ReleaseTitle}"/>

<entry key="version.Launcher-Common" value="${ReleaseTitle}"/>

<entry key="version.Client-Common" value="${ReleaseTitle}"/>

<entry key="version.Launcher-JP" value="${ReleaseTitle}"/>

<entry key="version.Client-JP" value="${ReleaseTitle}"/>

<entry key="version.Launcher-US" value="${ReleaseTitle}"/>

<entry key="version.Client-US" value="${ReleaseTitle}"/>

<entry key="version.RepositoryId" type="int" value="0"/>

<entry key="version.Launcher-CommonId" type="int" value="0"/>

<entry key="version.Client-CommonId" type="int" value="0"/>

<entry key="version.Launcher-JPId" type="int" value="0"/>

<entry key="version.Client-JPId" type="int" value="0"/>

<entry key="version.Launcher-USId" type="int" value="0"/>

<entry key="version.Client-USId" type="int" value="0"/>

</propertyfile>

<!--upload it-->

<ftp remotedir="${LivePackagePath}"

binary="no"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset file="${live.versions.filepath}"/>

</ftp>

</target>

<target name="help.update.Live.versions.file" depends="init" unless="${debug}">

<!-- update Live.versions file -->

<readPatchProjectForVersion property="Repository.latestVersion" srcFile="${LocalProductPath}/Repository/solid.patchproject"/>

<readPatchProjectForVersion property="Launcher-Common.latestVersion" srcFile="${LocalProductPath}/Launcher-Common/solid.patchproject"/>

<readPatchProjectForVersion property="Client-Common.latestVersion" srcFile="${LocalProductPath}/Client-Common/solid.patchproject"/>

<readPatchProjectForVersion property="Launcher-JP.latestVersion" srcFile="${LocalProductPath}/Launcher-JP/solid.patchproject"/>

<readPatchProjectForVersion property="Client-JP.latestVersion" srcFile="${LocalProductPath}/Client-JP/solid.patchproject"/>

<readPatchProjectForVersion property="Launcher-US.latestVersion" srcFile="${LocalProductPath}/Launcher-US/solid.patchproject"/>

<readPatchProjectForVersion property="Client-US.latestVersion" srcFile="${LocalProductPath}/Client-US/solid.patchproject"/>

<readPatchProjectForVersionId property="Repository.latestVersionId" srcFile="${LocalProductPath}/Repository/solid.patchproject"/>

<readPatchProjectForVersionId property="Launcher-Common.latestVersionId" srcFile="${LocalProductPath}/Launcher-Common/solid.patchproject"/>

<readPatchProjectForVersionId property="Client-Common.latestVersionId" srcFile="${LocalProductPath}/Client-Common/solid.patchproject"/>

<readPatchProjectForVersionId property="Launcher-JP.latestVersionId" srcFile="${LocalProductPath}/Launcher-JP/solid.patchproject"/>

<readPatchProjectForVersionId property="Client-JP.latestVersionId" srcFile="${LocalProductPath}/Client-JP/solid.patchproject"/>

<readPatchProjectForVersionId property="Launcher-US.latestVersionId" srcFile="${LocalProductPath}/Launcher-US/solid.patchproject"/>

<readPatchProjectForVersionId property="Client-US.latestVersionId" srcFile="${LocalProductPath}/Client-US/solid.patchproject"/>

<propertyfile file="${VersionFilesPath}/${live.versions.file.name}">

<entry key="version.Live" value="${ReleaseTitle}"/>

<entry key="version.Repository" value="${Repository.latestVersion}"/>

<entry key="version.Launcher-Common" value="${Launcher-Common.latestVersion}"/>

<entry key="version.Client-Common" value="${Client-Common.latestVersion}"/>

<entry key="version.Launcher-JP" value="${Launcher-JP.latestVersion}"/>

<entry key="version.Client-JP" value="${Client-JP.latestVersion}"/>

<entry key="version.Launcher-US" value="${Launcher-US.latestVersion}"/>

<entry key="version.Client-US" value="${Client-US.latestVersion}"/>

<entry key="version.RepositoryId" value="${Repository.latestVersionId}"/>

<entry key="version.Launcher-CommonId" value="${Launcher-Common.latestVersionId}"/>

<entry key="version.Client-CommonId" value="${Client-Common.latestVersionId}"/>

<entry key="version.Launcher-JPId" value="${Launcher-JP.latestVersionId}"/>

<entry key="version.Client-JPId" value="${Client-JP.latestVersionId}"/>

<entry key="version.Launcher-USId" value="${Launcher-US.latestVersionId}"/>

<entry key="version.Client-USId" value="${Client-US.latestVersionId}"/>

</propertyfile>

</target>

<target name="help.createTestBuildArtifactsDir">

<condition property="isLauncherProject" value="true" else="false">

<contains string="${Project}" substring="Launcher"/>

</condition>

<if>

<equals arg1="${isLauncherProject}" arg2="false"/>

<then>

<mkdir dir="${VersionedFilesPath}/${Project}"/>

</then>

</if>

</target>

<target name="help.sendCDNinvalidationRequest" if="${notDebug.notLocal}">

<cdninvalidate key="ourKey"

secretKey="--secret--"

force="false"

ignorecase="false"

paths="/${intermediate.path}/${ProductTitle}/${packagesPrefix}*"

responseKey="cdn.invalidate.response"

requestIdKey="cdn.invalidate.requestId"/>

<!-- Echo the error (target conditional upon whether errors exist) -->

<antcall target="help.echo.invalidate.error"/>

<!-- Fail the build if this wasn't successful -->

<fail unless="cdn.invalidate.requestId" message="No request id was persisted. Invalidation failed."/>

<!-- Persist the task properties -->

<antcall target="help.set.invalidate.done"/>

</target>

<target name="help.pollCDNinvalidationStatus" if="${notDebug.notLocal}">

<!-- Send out a status check periodically for each item in the cdnStatus.attempt.counter

Executes a target that can check properties at each execution (so we can 'update the loop'), and conditionally executes a 'real'

target that will actually perform the work. -->

<foreach list="${cdnStatus.attempt.counter}"

target="help.delegate.sendCDNinvalidationStatusCheck"

delimiter=","

inheritall="true"

param="num"/>

</target>

<!-- This target conditionally executes (but that doesn't work. I just left the unless condition for fun). What's important is that it first

reads in the persisted properties, and calls ANOTHER target, which conditionally executes. -->

<target name="help.delegate.sendCDNinvalidationStatusCheck" unless="cdn.status.percent.100" if="${notDebug.notLocal}">

<property file="${persisted.build.properties.file}"/>

<echo message="[--${num}] Delegating status check... "/>

<antcall target="help.sendCDNinvalidationStatusCheck"/>

<echo message="[--${num}] Done delegating status check. Status: ${cdn.status.percent.100}"/>

</target>

<!-- Intended to be called from help.pollCDNinvalidationStatus -->

<target name="help.sendCDNinvalidationStatusCheck" unless="cdn.status.percent.100" if="${notDebug.notLocal}">

<echo message="[--${num}] Checking CDN status for ${cdn.invalidate.requestId}"/>

<!-- Send status request. Use the id saved during invalidation -->

<cdnstatus key="ourKey"

secretKey="--secret--"

requestId="${cdn.invalidate.requestId}"

responseKey="cdn.status.response"

percentCompleteKey="cdn.status.percent"/>

<!-- If cdn.status.percent = 100, we set the property cdn.status.percent.100 to 100 -->

<!-- First, check if it's 100 -->

<condition property="cdn.status.percent.100" value="100">

<equals arg1="${cdn.status.percent}" arg2="100"/>

</condition>

<!-- If it is, run this conditional target to persist it -->

<antcall target="help.set.cdn.status.percent.100"/>

<!-- run a conditional wait target that reads properties, and fails if timeout-->

<antcall target="help.wait.between.polls"/>

</target>

<target name="help.wait.between.polls" unless="cdn.status.percent.100" if="${notDebug.notLocal}">

<!-- Read in the persisted properties -->

<property file="${persisted.build.properties.file}"/>

<!-- Wait for 1 minute - but check periodically for the property. If it's set, exit the wait. -->

<waitfor maxwait="1" maxwaitunit="minute" checkevery="10" checkeveryunit="second" timeoutproperty="cdn.invalidation.timeout.${num}">

<isset property="cdn.status.percent.100"/>

</waitfor>

<echo message="[--${num}] End wait: ${cdn.status.percent} and ${cdn.status.percent.100} and ${cdn.invalidation.timeout.1} and ${cdn.invalidation.timeout.10}"/>

<!-- fail the build if the timeout was reached for the last attempt. Have to check this *HERE*, because the property will not exist outside this target's scope -->

<!-- NOTE: The last digit of this property must equal the last number of the common.properties property: cdnStatus.attempt.counter -->

<fail if="cdn.invalidation.timeout.10" message="Final timeout reached attempting to get CDN invalidation status."/>

</target>

<target name="help.set.cdn.status.percent.100" if="cdn.status.percent.100">

<propertyfile file="${persisted.build.properties.file}">

<entry key="cdn.status.percent.100" value="100"/>

<entry key="cdn.status.response" value="${cdn.status.response}"/>

</propertyfile>

</target>

<target name="help.set.invalidate.done" if="cdn.invalidate.requestId">

<!-- Persist the response properties -->

<propertyfile file="${persisted.build.properties.file}">

<entry key="cdn.invalidate.response" value="${cdn.invalidate.response}"/>

<entry key="cdn.invalidate.requestId" value="${cdn.invalidate.requestId}"/>

</propertyfile>

</target>

<target name="help.echo.invalidate.error" if="cdn.invalidate.errorCode">

<echo message="cdn.invalidate error: ${cdn.invalidate.errorCode} | ${cdn.invalidate.errorMsg}"/>

</target>

<target name="help.fillTestFile">

<echo file="${BaseSourcePath}/${filename}" message="TestFile. Release:${ReleaseTitle}${line.separator}${BaseSourcePath}/${filename}"/>

</target>

<target name="help.makeCDNpackageDirs">

<antcall target="help.mkFtpDir.target">

<param name="remotedir.antcall" value="${LivetestPackagePath}"/>

</antcall>

<antcall target="help.mkFtpDir.target">

<param name="remotedir.antcall" value="${LivePackagePath}"/>

</antcall>

</target>

<target name="help.upload.ffs.file" unless="${debug}">

<ftp server="${cdn.root}"

remotedir="${intermediate.path}"

userid="${cdn.username}"

password="${cdn.password.ant}"

retriesAllowed="2"

binary="yes">

<fileset file="targetEnv/${ffs.file}"/>

</ftp>

</target>

<target name="help.deploy.Livetest.packagelists">

<!-- ===================Deploy US packagelist=================== -->

<antcall target="pac.deploy.packagelist">

<param name="packagelist.suffix" value="US"/>

<param name="packagelist.url" value="${LivetestPackageUrl}"/>

<param name="packagelist.remotedir" value="${LivetestPackagePath}"/>

</antcall>

<!-- ===================Deploy JP packagelist=================== -->

<antcall target="pac.deploy.packagelist">

<param name="packagelist.suffix" value="JP"/>

<param name="packagelist.url" value="${LivetestPackageUrl}"/>

<param name="packagelist.remotedir" value="${LivetestPackagePath}"/>

</antcall>

</target>

<target name="help.deploy.Live.packagelists">

<!-- ===================Deploy US packagelist=================== -->

<antcall target="pac.deploy.packagelist">

<param name="packagelist.suffix" value="US"/>

<param name="packagelist.url" value="${LivePackageUrl}"/>

<param name="packagelist.remotedir" value="${LivePackagePath}"/>

</antcall>

<!-- ===================Deploy JP packagelist=================== -->

<antcall target="pac.deploy.packagelist">

<param name="packagelist.suffix" value="JP"/>

<param name="packagelist.url" value="${LivePackageUrl}"/>

<param name="packagelist.remotedir" value="${LivePackagePath}"/>

</antcall>

</target>

<target name="help.ftp.rmdir" unless="${debug}">

<ftp action="del"

remotedir="${parent}"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset>

<include name="${dirToRemove}/**"/>

</fileset>

</ftp>

<ftp action="rmdir"

remotedir="${parent}/${dirToRemove}"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset>

<include name="**"/>

</fileset>

</ftp>

<ftp action="rmdir"

remotedir="${parent}"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset>

<include name="${dirToRemove}"/>

</fileset>

</ftp>

</target>

<target name="help.ftp.copyDir" unless="${debug}">

<property name="tempFtpDir" value="../../tempFtpDir"/>

<!-- Download the files to be copied -->

<ftp action="get"

remotedir="${fromDir}"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${tempFtpDir}">

<include name="*"/>

</fileset>

</ftp>

<help.mkFtpDir remotedir="${toDir}"/>

<!-- Upload the files to new location -->

<ftp remotedir="${toDir}"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${tempFtpDir}">

<include name="*"/>

</fileset>

</ftp>

<delete dir="${tempFtpDir}"/>

</target>

<!-- =================================================================================================== -->

<!-- CONDITIONAL PROPERTY TARGETS -->

<!-- =================================================================================================== -->

<!--

This critical target handles command-line properties (which includes those passed in by TeamCity),

and sets some properties that are used in common.properties. So it *MUST* come before common.properties is read

-->

<target name="props.pre.environment" unless="init.Complete">

<echo message="running the target: props.pre.environment"/>

<fail message="Really shouldn't deploy a SNAPSHOT build to the Live cdn.">

<condition>

<and>

<equals arg1="${build.type}" arg2="SNAPSHOT"/>

<equals arg1="${deploy.target}" arg2="prod"/>

</and>

</condition>

</fail>

<!-- Check this to avoid CDN invalidation when either debug=true or deploy.target=local -->

<condition property="notDebug.notLocal">

<and>

<not>

<istrue value="${debug}"/>

</not>

<not>

<equals arg1="${deploy.target}" arg2="local"/>

</not>

</and>

</condition>

<condition property="installer.build.suffix" value="SNAPSHOT" else="Live">

<equals arg1="${build.type}" arg2="SNAPSHOT"/>

</condition>

<condition property="build.suffix" value="SNAPSHOT">

<equals arg1="${build.type}" arg2="SNAPSHOT"/>

</condition>

<condition property="build.suffix" value="QA">

<and>

<equals arg1="${build.type}" arg2="RC"/>

<equals arg1="${deploy.target}" arg2="local"/>

</and>

</condition>

<condition property="build.suffix" value="Live">

<and>

<equals arg1="${build.type}" arg2="RC"/>

<equals arg1="${deploy.target}" arg2="prod"/>

</and>

</condition>

<fail unless="build.suffix" message="property build.suffix failed to get set in props.pre.environment."/>

<condition property="buildFromBranch" value="true" else="false">

<equals arg1="${build.type}" arg2="RC"/>

</condition>

<!-- Very important line here. -->

<property file="common.properties"/>

</target>

<target name="props.environment.1" depends="props.pre.environment, props.setForBranchArtifacts, props.setForTrunkArtifacts"

unless="init.Complete">

<echo message="running the target: props.environment.1"/>

<property name="installer.deploy.dir" value="${ProductTitle}Setup/${version}"/>

<!-- Read in deploy.target properties: -->

<property file="targetEnv/cdn.${deploy.target}.properties"/>

<property name="ProductUrl" value="${url.root}/${ProductPath}"/> <!--create.project, create.product-->

<property name="VersionFilesPath" value="${BaseSourcePath}/VersionFiles"/> <!-- .version files -->

<property name="VersionedFilesPath" value="${BaseSourcePath}/versioned"/> <!-- files that we update with SSN. They get patched. -->

<property name="UnversionedFilesPath" value="${BaseSourcePath}/unversioned"/> <!-- files that we DO NOT update with SSN. They DON'T get patched. -->

<property name="LivePackageUrl" value="${url.root}/${LivePackagePath}/"/><!-- Trailing slash is critical (and undocumented) -->

<property name="LivetestPackageUrl" value="${url.root}/${LivetestPackagePath}/"/><!-- Trailing slash is critical (and undocumented) -->

<property name="local.temp.pkgs.dir" value="${LocalProductPath}/tempPackages"/>

<!-- Properties holding information about which projects are being updated in this current update (an update might be 1.5.5, include,

say, just the Launcher and Client projects). This file is managed entirely by Ant. Don't edit it. -->

<property name="update.properties.file" value="${VersionFilesPath}/update.properties"/>

<!-- This file holds properties needed during the build, but created inside antcalls - so they don't persist beyond that target's scope. -->

<property name="persisted.build.properties.file" value="${VersionFilesPath}/persisted.build.properties"/>

</target>

<target name="props.environment.2" depends="clean" unless="init.Complete">

<echo message="running the target: props.environment.2"/>

<condition property="update.properties.file.available" value="true" else="false">

<available file="${update.properties.file}"/>

</condition>

<if>

<equals arg1="${update.properties.file.available}" arg2="true"/>

<then>

<!-- Read in our update.properties.file , but JUST THAT PROPERTY for now -->

<loadproperties srcFile="${update.properties.file}">

<filterchain>

<linecontains>

<contains value="update.properties.file.hasBeenUpdated"/>

</linecontains>

</filterchain>

</loadproperties>

</then>

</if>

<!-- So now, this target won't run if this file has already been updated completely -->

<target.foreach.project target="props.checkIfProject.isBeingUpdated"/>

<property file="${update.properties.file}"/> <!-- Read in the properties now that they've been set. Also necessary to conditionally execute 'clean' -->

<!-- Mark that we've updated this file, so we can avoid doing it again. Ever. Even on subsequent builds. -->

<propertyfile file="${update.properties.file}">

<entry key="update.properties.file.hasBeenUpdated" value="true"/>

</propertyfile>

<!-- Set that property in memory, as well. -->

<property name="update.properties.file.hasBeenUpdated" value="true"/>

</target>

<target name="props.setForBranchArtifacts" if="${buildFromBranch}">

<property name="ReleaseTitle" value="${version}"/>

<property name="ProductTitle" value="${ProductTitleBase}"/>

<property name="BaseSourcePath" value="${BuildArtifacts.dir}/${ProductTitle}/${ReleaseTitle}"/>

<property name="CurrentVersionFilesPath" value="${BuildArtifacts.dir}/${ProductTitle}/CurrentVersionFiles"/>

<property name="ProductPath" value="${intermediate.path}/${ProductTitle}"/>

<property name="LocalProductPath" value="${ProductsBaseDir}/Products/${ProductTitle}"/>

<!-- branch: .../NSIS_Installer/output/Faxion/1.1 -->

<property name="installerOutput.dir" value="${nsis.main.dir}/output/${ProductTitle}/${ReleaseTitle}"/>

<property name="LivetestPackagePath" value="${intermediate.path}/${ProductTitle}/${packagesPrefix}Livetest"/>

<property name="LivePackagePath" value="${intermediate.path}/${ProductTitle}/${packagesPrefix}Live"/>

</target>

<target name="props.setForTrunkArtifacts" unless="${buildFromBranch}">

<failIfProd/>

<!-- Trunk builds have a special target location (version-SNAPSHOT rather than just (version) -->

<property name="ReleaseTitle" value="${version}-${build.suffix}-${my.BUILD_NUMBER}"/>

<property name="ProductTitle" value="${ProductTitleBase}-${build.suffix}"/>

<property name="BaseSourcePath" value="${BuildArtifacts.dir}/${ProductTitle}/${version}/${my.BUILD_NUMBER}"/>

<property name="CurrentVersionFilesPath" value="${BuildArtifacts.dir}/${ProductTitle}/${version}/CurrentVersionFiles"/>

<property name="ProductPath" value="${intermediate.path}/${ProductTitle}-${version}"/>

<property name="LocalProductPath" value="${ProductsBaseDir}/Products/${ProductTitle}-${version}"/>

<!-- trunk : .../NSIS_Installer/output/Faxion-SNAPSHOT/1.1/1 -->

<property name="installerOutput.dir" value="${nsis.main.dir}/output/${ProductTitle}/${version}/${my.BUILD_NUMBER}"/>

<property name="LivetestPackagePath" value="${intermediate.path}/${ProductTitle}-${version}/${packagesPrefix}Livetest"/>

<property name="LivePackagePath" value="${intermediate.path}/${ProductTitle}-${version}/${packagesPrefix}Live"/>

</target>

<target name="props.create.project">

<!--If this is the Launcher project, VCDiffType is "None"-->

<condition property="VCDiffType" value="None">

<contains string="${Project}" substring="Launcher"/>

</condition>

<!--If this is the Repository project, set up its relative path-->

<condition property="RelativePath" value="${RepoRelativePath}">

<equals arg1="${Project}" arg2="Repository"/>

</condition>

<!--If this is the Client project, set up its relative path-->

<condition property="RelativePath" value="${ClientRelativePath}">

<contains string="${Project}" substring="Client"/>

</condition>

<!--Otherwise, set the default-->

<property name="RelativePath" value=""/>

</target>

<target name="props.deploy.package">

<!--If this is the Launcher project, Restart is "True"-->

<condition property="Restart" value="true">

<contains string="${Project}" substring="Launcher"/>

</condition>

</target>

<!--

This target checks the BuildArtifacts location, looking for a directory for the specified projectToCheck.

If it finds one, then that project is getting updated, and props.update.updatePropertiesFile is called

for that project.

It sets the property "isBeingUpdated" so that props.update.updatePropertiesFile will have it available

when that's called. But, since this target is called from an antcall, "isBeingUpdated" won't persist

once this target returns (and can therefore be re-used for each project).

-->

<target name="props.checkIfProject.isBeingUpdated" unless="${update.properties.file.hasBeenUpdated}">

<echo message="running the target: props.checkIfProject.isBeingUpdated for ${Project}"/>

<condition property="isBeingUpdated" value="true">

<available file="${VersionedFilesPath}/${Project}" type="dir"/>

</condition>

<antcall target="props.update.updatePropertiesFile">

<param name="isBeingUpdated" value="${isBeingUpdated}"/>

</antcall>

<echo message="PROJECT UPDATE: ${isBeingUpdated}: is ${VersionedFilesPath}/${Project} being updated?"/>

</target>

<!--

This target updates the update.properties.file for the specified project, setting it to "true".

It will only run, however, if property "isBeingUpdated" is true. That property currently only

exists when called from props.checkIfProject.isBeingUpdated.

-->

<target name="props.update.updatePropertiesFile" if="${isBeingUpdated}">

<echo message="running the target props.update.updatePropertiesFile for ${Project}"/>

<dirname property="update.properties.file.dir" file="${update.properties.file}"/>

<mkdir dir="${update.properties.file.dir}"/>

<propertyfile file="${update.properties.file}">

<entry key="${Project}.isBeingUpdated" value="true"/>

<entry key="updated.projects.list" value="${Project} " operation="+"/> <!-- space is intentional -->

</propertyfile>

</target>

<target name="props.checkDeployTargetEqualsProd" depends="init">

<condition property="deployTargetEqualsProd" value="true" else="false">

<equals arg1="${deploy.target}" arg2="prod"/>

</condition>

</target>

<!-- =================================================================================================== -->

<!-- FUNCTIONAL TARGETS -->

<!-- =================================================================================================== -->

<target name="pac.create.product" depends="init, clean.pac.create.product">

<failIfProd/>

<property file="pac/create.product.properties"/>

<echo message="running the target: pac.create.product"/>

<antcall target="help.upload.ffs.file"/>

<!--Copy the command file template-->

<property name="commandfile.template" value="create.product.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${ProductTitle}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%Title%" value="${Title}"/>

<replace file="${pac.commandfile}" token="%AuthorizationUrl%" value="${AuthorizationUrl}"/>

<antcall target="help.execute_pac"/>

</target>

<target name="pac.create.project" depends="init, props.create.project">

<failIfProd/>

<property file="pac/create.project.properties"/>

<echo message="running the target: pac.create.project on ${Project}"/>

<!--Copy the command file template-->

<property name="commandfile.template" value="create.project.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${Project}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%Title%" value="${Title}"/>

<replace file="${pac.commandfile}" token="%Enabled%" value="${Enabled}"/>

<replace file="${pac.commandfile}" token="%ProjectType%" value="${ProjectType}"/>

<replace file="${pac.commandfile}" token="%VCDiffType%" value="${VCDiffType}"/>

<replace file="${pac.commandfile}" token="%ContentUrl%" value="${ContentUrl}"/>

<replace file="${pac.commandfile}" token="%PackageUrl%" value="${LivePackageUrl}"/>

<replace file="${pac.commandfile}" token="%RelativePath%" value="${RelativePath}"/>

<replace file="${pac.commandfile}" token="%DestructiveUpdate%" value="${DestructiveUpdate}"/>

<replace file="${pac.commandfile}" token="%ProcessDeleteManifest%" value="${ProcessDeleteManifest}"/>

<replace file="${pac.commandfile}" token="%PerformExpand%" value="${PerformExpand}"/>

<replace file="${pac.commandfile}" token="%PerformPostExpandDelete%" value="${PerformPostExpandDelete}"/>

<antcall target="help.execute_pac"/>

</target>

<!-- Builds the patches locally -->

<target name="pac.release" depends="init">

<failIfProd/>

<property file="pac/release.properties"/>

<echo message="running the target: pac.release on ${Project}"/>

<antcall target="failIfDirectoryNotFound">

<param name="directoryName" value="${SourcePath}"/>

</antcall>

<!--Copy the command file template-->

<property name="commandfile.template" value="release.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${Project}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<delete file="${pac.commandfile}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%ProjectTitle%" value="${ProjectTitle}"/>

<replace file="${pac.commandfile}" token="%Title%" value="${Title}"/>

<replace file="${pac.commandfile}" token="%SourcePath%" value="${SourcePath}"/>

<replace file="${pac.commandfile}" token="%BaseLine%" value="${BaseLine}"/>

<replace file="${pac.commandfile}" token="%AvailableReleases%" value="${AvailableReleases}"/>

<replace file="${pac.commandfile}" token="%DifferentialExclusionList%" value="${DifferentialExclusionList}"/>

<antcall target="help.execute_pac"/>

<antcall target="help.writeVersionFile"/>

</target>

<!-- Deploy patches to CDN -->

<target name="pac.deploy.content" depends="init">

<property file="pac/deploy.content.properties"/>

<echo message="running the target: pac.deploy.content on ${Project}"/>

<antcall target="help.mkFtpDir.target">

<param name="remotedir.antcall" value="${ProductPath}"/>

</antcall>

<!--Copy the command file template-->

<property name="commandfile.template" value="deploy.content.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${Project}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%ProjectTitle%" value="${ProjectTitle}"/>

<replace file="${pac.commandfile}" token="%ReleaseTitle%" value="${ReleaseTitle}"/>

<replace file="${pac.commandfile}" token="%Retries%" value="${Retries}"/>

<!-- UploadSite 1 -->

<replace file="${pac.commandfile}" token="%ContentRoot1%" value="${ContentRoot1}"/>

<replace file="${pac.commandfile}" token="%UserName1%" value="${UserName1}"/>

<replace file="${pac.commandfile}" token="%Password1%" value="${Password1}"/>

<replace file="${pac.commandfile}" token="%IsPassive1%" value="${IsPassive1}"/>

<replace file="${pac.commandfile}" token="%KeepAlive1%" value="${KeepAlive1}"/>

<antcall target="help.execute_pac"/>

</target>

<!-- Verifies the deployment of patches to CDN -->

<target name="pac.verify.content" depends="init">

<property file="pac/verify.content.properties"/>

<echo message="running the target: pac.verify.content on ${Project}"/>

<!--Copy the command file template-->

<property name="commandfile.template" value="verify.content.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${Project}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%ReleaseTitle%" value="${ReleaseTitle}"/>

<replace file="${pac.commandfile}" token="%ProjectTitle%" value="${ProjectTitle}"/>

<replace file="${pac.commandfile}" token="%TimeoutMinutes%" value="${TimeoutMinutes}"/>

<antcall target="help.execute_pac"/>

</target>

<!-- Injects the patch content into SSN's Distributed Delivery Network system. -->

<target name="pac.deploy.ddn" depends="init">

<property file="pac/deploy.ddn.properties"/>

<echo message="running the target: pac.deploy.ddn on ${Project}"/>

<!--Copy the command file template-->

<property name="commandfile.template" value="deploy.ddn.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${Project}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%ReleaseTitle%" value="${ReleaseTitle}"/>

<replace file="${pac.commandfile}" token="%ProjectTitle%" value="${ProjectTitle}"/>

<replace file="${pac.commandfile}" token="%UserName%" value="${UserName}"/>

<replace file="${pac.commandfile}" token="%Password%" value="${Password}"/>

<replace file="${pac.commandfile}" token="%NetworkGroup%" value="${NetworkGroup}"/>

<replace file="${pac.commandfile}" token="%PieceSize%" value="${PieceSize}"/>

<antcall target="help.execute_pac"/>

</target>

<!-- Uploads a project's .package file to the CDN. -->

<target name="pac.deploy.package" depends="init,props.deploy.package,help.makeCDNpackageDirs">

<property file="pac/deploy.package.properties"/>

<echo message="running the target: pac.deploy.package on ${Project}"/>

<!--Copy the command file template-->

<property name="commandfile.template" value="deploy.package.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${Project}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%ProjectTitle%" value="${ProjectTitle}"/>

<replace file="${pac.commandfile}" token="%ReleaseTitle%" value="${ReleaseTitle}"/>

<replace file="${pac.commandfile}" token="%Restart%" value="${Restart}"/>

<replace file="${pac.commandfile}" token="%Required%" value="${Required}"/>

<!-- UploadSite 1 -->

<replace file="${pac.commandfile}" token="%PackageRoot1%" value="${PackageRoot1}"/>

<replace file="${pac.commandfile}" token="%UserName1%" value="${UserName1}"/>

<replace file="${pac.commandfile}" token="%Password1%" value="${Password1}"/>

<replace file="${pac.commandfile}" token="%IsPassive1%" value="${IsPassive1}"/>

<replace file="${pac.commandfile}" token="%KeepAlive1%" value="${KeepAlive1}"/>

<antcall target="help.execute_pac"/>

</target>

<!-- Uploads a product's .packagelist to the CDN. Requires a packagelist.suffix property. (ie US or JP)-->

<target name="pac.deploy.packagelist" depends="init,help.makeCDNpackageDirs">

<property file="pac/deploy.packagelist.properties"/>

<echo message="running the target: pac.deploy.packagelist"/>

<!--Copy the command file template-->

<property name="packageList.template" value="deploy.packagelist.xml"/>

<property name="pac.packageList" value="${pac.dir}/${ProductTitle}-${packagelist.suffix}.packagelist"/>

<copy file="pac/${packageList.template}" tofile="${pac.packageList}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.packageList}" token="%Url%" value="${packagelist.url}"/>

<replace file="${pac.packageList}" token="%Project1%" value="${Project1}"/>

<replace file="${pac.packageList}" token="%ExpansionPath1%" value="${ExpansionPath1}"/>

<replace file="${pac.packageList}" token="%Project2%" value="${Project2}"/>

<replace file="${pac.packageList}" token="%ExpansionPath2%" value="${ExpansionPath2}"/>

<replace file="${pac.packageList}" token="%Project3%" value="${Project3}"/>

<replace file="${pac.packageList}" token="%ExpansionPath3%" value="${ExpansionPath3}"/>

<replace file="${pac.packageList}" token="%Project4%" value="${Project4}"/>

<replace file="${pac.packageList}" token="%ExpansionPath4%" value="${ExpansionPath4}"/>

<replace file="${pac.packageList}" token="%Project5%" value="${Project5}"/>

<replace file="${pac.packageList}" token="%ExpansionPath5%" value="${ExpansionPath5}"/>

<antcall target="help.packagelist.ftp">

<param name="remotedir" value="${packagelist.remotedir}/"/>

</antcall>

</target>

<!-- Edits an existing project.

Used when redeploying patches to another server. Urls (to content and packages) must be changed. -->

<target name="pac.edit.project" depends="init">

<property file="pac/edit.project.properties"/>

<echo message="running the target: pac.edit.project on ${Project}"/>

<!--Copy the command file template-->

<property name="commandfile.template" value="edit.project.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${Project}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%Title%" value="${Title}"/>

<replace file="${pac.commandfile}" token="%PackageUrl%" value="${PackageUrl}"/>

<replace file="${pac.commandfile}" token="%ContentUrl%" value="${ContentUrl}"/>

<antcall target="help.execute_pac"/>

</target>

<!-- Edits an existing product.

Used when redeploying patches to another server. AuthorizationUrl (.ffs file url) must be changed. -->

<target name="pac.edit.product" depends="init">

<property file="pac/edit.product.properties"/>

<echo message="running the target: pac.edit.product"/>

<!--Copy the command file template-->

<property name="commandfile.template" value="edit.product.xml"/>

<property name="pac.commandfile" value="${pac.dir}/pac-(${ProductTitle}-${ReleaseTitle}-${build.type})-${commandfile.template}"/>

<copy file="pac/${commandfile.template}" tofile="${pac.commandfile}" overwrite="true"/>

<!--Substitute real values-->

<replace file="${pac.commandfile}" token="%LocalProductPath%" value="${LocalProductPath}"/>

<replace file="${pac.commandfile}" token="%Title%" value="${Title}"/>

<replace file="${pac.commandfile}" token="%AuthorizationUrl%" value="${AuthorizationUrl}"/>

<antcall target="help.execute_pac"/>

</target>

<!-- =================================================================================================== -->

<!-- Faxion Targets -->

<!-- =================================================================================================== -->

<target name="faxion.createTestProductFiles" depends="init.createTestProductFiles,init" description="Builds a bunch of fake files in the BuildArtifacts dir that resemble a product. For testing.">

<!-- After PLINST-152 is done, use those lists. For now, just make fake stuff. -->

<target.foreach.project target="help.createTestBuildArtifactsDir"/>

<mkdir dir="${VersionedFilesPath}/Repository/assets"/>

<mkdir dir="${UnversionedFilesPath}/Client-Common"/>

<delete dir="${VersionedFilesPath}/Launcher-Common/html/wmv"/> <!-- delete the large wmv file(s). -->

<loadfile srcfile="expectedFilelists/testFileList.txt" property="fileList"/>

<propertyregex property="test.file.list"

input="${fileList}"

regexp="${line.separator}"

replace=","

casesensitive="false"/>

<filelist id="testFiles" dir="${BaseSourcePath}" files="${test.file.list}"/>

<touch>

<filelist refid="testFiles"/>

</touch>

<foreach list="${test.file.list}" target="help.fillTestFile" param="filename" inheritall="true"/>

<delete dir="${VersionFilesPath}"/>

</target>

<target name="faxion.InitialProduct" depends="init,help.create.Live.versions.file"

description="Creates the Faxion product and initial releases of the projects. Includes packagelist.">

<failIfProd/>

<!-- Create Product -->

<antcall target="pac.create.product"/>

<!-- Create Projects -->

<target.foreach.project target="pac.create.project"/>

<antcall target="help.deploy.Livetest.packagelists"/>

<antcall target="help.deploy.Live.packagelists"/>

<!-- Create the first update, and deploy to Livetest and Live (local, of course) -->

<antcall target="faxion.UpdateProduct"/>

</target>

<target name="faxion.UpdateProduct" depends="init" description="Builds patches for all projects, runs Livetest and Live. (Should be done with deploy.target=local.)">

<failIfProd/>

<antcall target="faxion.buildPatches"/>

<antcall target="faxion.deploy.Livetest"/>

<antcall target="faxion.deploy.Live"/>

</target>

<target name="faxion.CDNinvalidation" depends="init"

description="Sends request. Waits some minutes. Polls for some interval. Continues, or fails if no response." if="${notDebug.notLocal}">

<failIfLocal/>

<!-- Send the invalidation request, which fails itself if the task fails -->

<antcall target="help.sendCDNinvalidationRequest"/>

<!-- Read in properties that were persisted -->

<property file="${persisted.build.properties.file}"/>

<!-- Takes some time before status is available... -->

<echo message="Starting initial wait before checking status the first time..."/>

<waitfor maxwait="5" maxwaitunit="minute">

<isset property="never.will.be.set"/>

</waitfor>

<!-- Done waiting. Start polling for status -->

<antcall target="help.pollCDNinvalidationStatus"/>

</target>

<target name="faxion.buildPatches" depends="init" description="Runs SSN release step on each Project.">

<failIfProd/>

<!-- project.buildPatches for each -->

<target.foreach.project target="project.buildPatches"/>

</target>

<target name="faxion.deploy.Livetest" depends="init" description="Deploys a product to Livetest (on either local or prod). Uploads installers, if prod." unless="${debug}">

<!-- edit the product first, so AuthorizationUrl is correct for this deployment -->

<antcall target="pac.edit.product"/>

<antcall target="help.deploy.Livetest.packagelists"/>

<!-- project.deploy.Livetest for each -->

<target.foreach.project target="project.deploy.Livetest"/>

<!-- update packages-Livetest/Live.versions -->

<!-- update Live.versions file -->

<antcall target="help.update.Live.versions.file"/>

<!-- upload Live.versions to packages-Livetest -->

<ftp remotedir="${LivetestPackagePath}"

binary="no"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}"

skipFailedTransfers="false">

<fileset dir="${VersionFilesPath}">

<include name="${live.versions.file.name}"/>

</fileset>

</ftp>

<!-- CDN Invalidation -->

<antcall target="faxion.CDNinvalidation"/>

<!-- upload installers -->

<!--<antcall target="faxion.UploadInstallers"/>--> <!-- PLINST-169 Too slow -->

</target>

<target name="faxion.deploy.Live" depends="init" description="Makes Live patches accessible to Live clients. Backs up Live packages." unless="${debug}">

<!-- edit the product first, so AuthorizationUrl is correct for this deployment -->

<antcall target="pac.edit.product"/>

<antcall target="help.deploy.Live.packagelists"/>

<!-- project.deploy.Live for each -->

<target.foreach.project target="project.deploy.Live"/>

<!-- get current (new) Live package files (incl Live.versions) into temp dir to back them up on the CDN -->

<ftp action="get"

remotedir="${LivePackagePath}"

binary="no"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${local.temp.pkgs.dir}">

<include name="*"/>

</fileset>

</ftp>

<!-- update Live.versions file -->

<antcall target="help.update.Live.versions.file"/>

<!-- Read in the updated Live.versions properties file. This moment is part of what the whole Live.versions thing is about.

Here, we use it to decide the name of the packages-<> directory to back up the package files to. (ie packages-1.6.2) -->

<property file="${VersionFilesPath}/${live.versions.file.name}"/>

<!-- create backup dir for this new release (packages-${version}) -->

<condition property="live.backup.dir"

value="${ProductPath}/${packagesPrefix}${version.Live}"

else="${ProductPath}/${packagesPrefix}${version}-${my.BUILD_NUMBER}">

<equals arg1="${buildFromBranch}" arg2="true"/>

</condition>

<antcall target="help.mkFtpDir.target">

<param name="remotedir.antcall" value="${live.backup.dir}"/>

</antcall>

<!-- upload temp dir package files (incl Live.versions) to backup dir on CDN -->

<ftp remotedir="${live.backup.dir}"

binary="no"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${local.temp.pkgs.dir}">

<include name="*"/>

</fileset>

</ftp>

<!-- upload Live.versions to packages-Live -->

<ftp remotedir="${LivePackagePath}"

binary="no"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${VersionFilesPath}">

<include name="${live.versions.file.name}"/>

</fileset>

</ftp>

<!-- CDN Invalidation -->

<antcall target="faxion.CDNinvalidation"/>

</target>

<!-- The FaxionInstaller build uploads the installers locally. So, we only want to upload the installers if we're running the Livetest target against prod -->

<target name="faxion.UploadInstallers" depends="init,props.checkDeployTargetEqualsProd"

description="Uploads previously built Release Candidate installers to a prod CDN." if="${deployTargetEqualsProd}">

<!-- Make this not fail if installers are not available -->

<failIfLocal/>

<antcall target="help.upload.installers">

<param name="LOCALE" value="US"/>

</antcall>

<antcall target="help.upload.installers">

<param name="LOCALE" value="JP"/>

</antcall>

</target>

<target name="faxion.rollbackRelease.QA" depends="init" description="Rolls back the specified release from the QA (rc,local) deployment.">

<failIfProd/>

<!-- =====================Evaluate all needed properties ====================== -->

<!-- Read in the updates and versions of the release to rollback -->

<property file="${update.properties.file}"/> <!-- Need updated.projects.list -->

<condition property="ProductSourcePath"

value="${BuildArtifacts.dir}/${ProductTitle}"

else ="${BuildArtifacts.dir}/${ProductTitle}/${version}">

<equals arg1="${buildFromBranch}" arg2="true"/>

</condition>

<!--get a list of all update directories for this product -->

<dirset id="product.latest.update.dirs" dir="${ProductSourcePath}" erroronmissingdir="true">

<exclude name="CurrentVersionFiles"/>

<include name="**"/>

<depth min="0" max="0"/>

</dirset>

<!-- sort all those directories and isolate the latest into a property. -->

<pathconvert property="product.latest.update.dir" pathsep=",">

<first>

<last count="2">

<sort>

<dirset refid="product.latest.update.dirs"/>

</sort>

</last>

</first>

</pathconvert>

<!-- previousReleaseName will be "1.6.2" for branch builds and "2" for trunk builds -->

<propertyregex property="previousReleaseName"

input="${product.latest.update.dir}"

regexp=".*\\([^\.].*)"

select="\1"

casesensitive="false"/>

<echo message="previous release dir : ${product.latest.update.dir}"/>

<echo message="previous release name: ${previousReleaseName}"/>

<!-- previousReleaseName is equivalent to my.BUILD_NUMBER for SNAPSHOT builds -->

<!--

branch: BuildArtifacts/Faxion/1.0/VersionFiles

trunk : BuildArtifacts/Faxion-SNAPSHOT/1.0/0/VersionFiles

-->

<condition property="previous.versionFiles.dir"

value="${BuildArtifacts.dir}/${ProductTitle}/${previousReleaseName}/VersionFiles"

else="${BuildArtifacts.dir}/${ProductTitle}/${version}/${previousReleaseName}/VersionFiles"><!--Can't use ReleaseTitle, because it's 1.6-SNAPSHOT-2 or something.-->

<equals arg1="${buildFromBranch}" arg2="true"/>

</condition>

<!--

branch: /faxion-QA/Faxion/packages-1.0

trunk : /faxion-QA/Faxion-SNAPSHOT/packages-1.0-0

-->

<condition property="previous.packages.dir"

value="${ProductPath}/${packagesPrefix}${previousReleaseName}"

else="${ProductPath}/${packagesPrefix}${version}-${previousReleaseName}"><!--Can't use ReleaseTitle, because it's 1.6-SNAPSHOT-2 or something.-->

<equals arg1="${buildFromBranch}" arg2="true"/>

</condition>

<!--

branch: /faxion-QA/Faxion/packages-1.1

trunk : /faxion-QA/Faxion-SNAPSHOT/packages-1.0-1

-->

<condition property="current.packages.dir"

value="${packagesPrefix}${ReleaseTitle}"

else="${packagesPrefix}${version}-${my.BUILD_NUMBER}"><!--Can't use ReleaseTitle, because it's 1.6-SNAPSHOT-2 or something.-->

<equals arg1="${buildFromBranch}" arg2="true"/>

</condition>

<!--

branch: .../NSIS_Installer/output/Faxion/1.1

trunk : .../NSIS_Installer/output/Faxion-SNAPSHOT/1.0/1

-->

<condition property="installer.output.dir"

value="${nsis.main.dir}/output/${ProductTitle}/${ReleaseTitle}"

else="${nsis.main.dir}/output/${ProductTitle}/${version}/${my.BUILD_NUMBER}">

<equals arg1="${buildFromBranch}" arg2="true"/>

</condition>

<echo message="previous.versionFiles.dir : ${previous.versionFiles.dir}"/>

<echo message="previous.packages.dir : ${previous.packages.dir}"/>

<echo message="current.packages.dir : ${current.packages.dir}"/>

<echo message="installer.output.dir : ${installer.output.dir}"/>

<!-- ======================= FaxionInstaller ================================== -->

<!--delete NSIS_Installer/output/Product/<version>-->

<delete dir="${installer.output.dir}"/>

<!-- ========================= Project rollback =============================== -->

<!-- use the list of projects that were updated in that release (in update.properties.file) -->

<foreach target="project.rollback.QA" list="${updated.projects.list}" delimiter=" " param="Project" inheritall="true" trim="true">

<param name="previousReleaseName" value="${previousReleaseName}"/>

</foreach>

<!-- ========================= BuildArtifacts Dir ============================= -->

<!-- regress CurrentVersionFiles -->

<echo message="Copying ${previous.versionFiles.dir}/*.version to ${CurrentVersionFilesPath}"/>

<copy todir="${CurrentVersionFilesPath}" overwrite="true">

<fileset dir="${previous.versionFiles.dir}" includes="*.version"/>

</copy>

<if> <!-- If just the patch-creation went bad, we might not want to delete BuildArtifacts. They're probably the only copy we have.

This is false by default. Do a custom build to clear them if you need to. Or do it manually. -->

<equals arg1="${rollback.includeBuildArtifacts}" arg2="true"/>

<then>

<!--delete BuildArtifacts/<Product>/<version> WARNING!!!! But not before you've done project rollback. Need update.properties.file. WARNING!!!! -->

<delete dir="${BuildArtifacts.dir}/${ProductTitle}/${version}"/>

</then>

<else>

<!--Well, delete the VersionFiles no matter what. -->

<!--delete BuildArtifacts/<Product>/<version>/VersionFiles WARNING!!!! But not before you've done project rollback. Need update.properties.file. WARNING!!!! -->

<delete dir="${VersionFilesPath}"/>

</else>

</if>

<!-- ========================= Product Dir ==================================== -->

<!-- regress ProductDir/Product/*.package by simply downloading packages-${previousReleaseName} into the ProductDir -->

<echo message=" regress ${LocalProductPath}/*.package by simply downloading ${previous.packages.dir} into it "/>

<ftp action="get"

remotedir="${previous.packages.dir}"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${LocalProductPath}">

<include name="*.package"/>

</fileset>

</ftp>

<!-- ============================ CDN ========================================= -->

<property name="livePackages" value="${packagesPrefix}Live"/>

<property name="livetestPackages" value="${packagesPrefix}Livetest"/>

<!-- backup Livetest packagelists locally ${LivetestPackagePath}. Do this BEFORE deleting the packages-Livetest dir -->

<echo message="backup Livetest packagelists (from ${LivetestPackagePath}) locally at ${local.temp.pkgs.dir}"/>

<ftp action="get"

remotedir="${LivetestPackagePath}"

binary="no"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${local.temp.pkgs.dir}">

<include name="*.packagelist"/>

</fileset>

</ftp>

<!--delete /faxion-QA/Product/packages-Live-->

<echo message="delete /${ProductPath}/${livePackages}"/>

<antcall target="help.ftp.rmdir">

<param name="parent" value="${ProductPath}"/>

<param name="dirToRemove" value="${livePackages}"/>

</antcall>

<!--delete /faxion-QA/Product/packages-Livetest-->

<echo message="delete /${ProductPath}/${livetestPackages}"/>

<antcall target="help.ftp.rmdir">

<param name="parent" value="${ProductPath}"/>

<param name="dirToRemove" value="${livetestPackages}"/>

</antcall>

<!--delete /faxion-QA/Product/packages-<ReleaseTitle>-->

<echo message="delete /${ProductPath}/${current.packages.dir}"/>

<antcall target="help.ftp.rmdir">

<param name="parent" value="${ProductPath}"/>

<param name="dirToRemove" value="${current.packages.dir}"/>

</antcall>

<!--copy /faxion-QA/Product/packages-<previousVersion> to packages-Live-->

<echo message="copy /${previous.packages.dir} to ${ProductPath}/${livePackages}"/>

<antcall target="help.ftp.copyDir">

<param name="fromDir" value="${previous.packages.dir}"/>

<param name="toDir" value="${ProductPath}/${livePackages}"/>

</antcall>

<!--copy /faxion-QA/Product/packages-<previousVersion> to packages-Livetest-->

<echo message="copy ${previous.packages.dir} to ${ProductPath}/${livetestPackages}"/>

<antcall target="help.ftp.copyDir">

<param name="fromDir" value="${previous.packages.dir}"/>

<param name="toDir" value="${ProductPath}/${livetestPackages}"/>

</antcall>

<!--Now put the Livetest packagelists in place-->

<echo message="Now put the Livetest packagelists in place at: ${LivetestPackagePath}"/>

<ftp remotedir="${LivetestPackagePath}"

binary="no"

server="${cdn.root}"

userid="${cdn.username}"

password="${cdn.password.ant}">

<fileset dir="${local.temp.pkgs.dir}">

<include name="*.packagelist"/>

</fileset>

</ftp>

</target>

<!-- =================================================================================================== -->

<!-- Project Targets -->

<!-- =================================================================================================== -->

<target name="project.rollback.QA" depends="init">

<property file="${update.properties.file}"/>

<property file="${VersionFilesPath}/${live.versions.file.name}"/>

<propertycopy property="releaseId" from="version.${Project}Id"/>

<!-- ========================= Product Dir ==================================== -->

<!-- delete ProductDir/Project/<releaseDir> -->

<delete dir="${LocalProductPath}/${Project}/${releaseId}"/>

<!-- regress ProductDir/Product/Project/solid.patchproject (delete <Release> element containing Title=previousReleaseName) -->

<echo message="regress ${LocalProductPath}/${Project}/solid.patchproject"/>

<!-- This regexp captures 3 parts. Part 2 is the one we want to delete. So just replace all 3 with 1 and 3, leaving 2 out. -->

<property name="regexp.Pattern" value="(.*&lt;/Release&gt;.*)(&lt;Release&gt;.*&lt;Title&gt;${ReleaseTitle}&lt;/Title&gt;.*&lt;/Release&gt;)(.*)"/>

<replaceregexp file="${LocalProductPath}/${Project}/solid.patchproject"

match="${regexp.Pattern}"

flags="s"

replace="\1\3"/>

<!-- ============================ CDN ========================================= -->

<!-- delete /faxion-QA/Product/Project/<releaseId>-->

<echo message="delete /${ProductPath}/${Project}/${releaseId}"/>

<antcall target="help.ftp.rmdir">

<param name="parent" value="${ProductPath}/${Project}"/>

<param name="dirToRemove" value="${releaseId}"/>

</antcall>

</target>

<!-- Why have this additional target wrapping pac.release? So we can conditionally execute it. -->

<target name="project.buildPatches" depends="init" if="${Project}.isBeingUpdated">

<echo message="running the target: project.buildPatches on ${Project}"/>

<!-- Project property is passed in by a calling target -->

<antcall target="pac.release">

<param name="Project" value="${Project}"/>

</antcall>

</target>

<target name="project.deploy.Livetest" depends="init" if="${Project}.isBeingUpdated">

<echo message="running the target: project.deploy.Livetest on ${Project}"/>

<!-- edit the project first, so Content and Package URLs are correct for this deployment -->

<antcall target="pac.edit.project">

<param name="PackageUrl" value="${LivetestPackageUrl}"/>

</antcall>

<antcall target="pac.deploy.content"/>

<antcall target="pac.verify.content"/>

<antcall target="pac.deploy.ddn"/>

<antcall target="pac.deploy.package">

<param name="PackageRoot1" value="ftp://${cdn.root}/${LivetestPackagePath}"/>

</antcall>

</target>

<target name="project.deploy.Live" depends="init" if="${Project}.isBeingUpdated">

<echo message="running the target: project.deploy.Live on ${Project}"/>

<!-- edit the project first, so Content and Package URLs are correct for this deployment -->

<antcall target="pac.edit.project">

<param name="PackageUrl" value="${LivePackageUrl}"/>

</antcall>

<antcall target="pac.deploy.package">

<param name="PackageRoot1" value="ftp://${cdn.root}/${LivePackagePath}"/>

</antcall>

</target>

</project>