Rev 2067 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<project name="ant-subversion"><description>This ant file requires the use of jars in JavaSVN and svnant.This ant file provides a macro for sync'ing between a subversioncheckout and another (newer) directory. The idea being that youwant subversion to look like the sync directory. Refer to thedocumentation above the macrodef for the svnsync macro for moreinformation.In addition, this will only work with JavaSVN version1.0.4005.cots or later due to the fact that previous versionsof JavaSVN has a verion number in the svnClientAdapter jar.</description><!-- define the subversion tasks --><taskdef resource="svntask.properties"><classpath><pathelement path="${using.JavaSVN.basedir}/jar/javasvn.jar"/><pathelement path="${using.JavaSVN.basedir}/jar/javasvn-javahl.jar"/><pathelement path="${using.JavaSVN.basedir}/jar/svnClientAdapter.jar"/><pathelement path="${using.svnant.basedir}/jar/svnant.jar"/></classpath></taskdef><!-- svnsyncThis macro will sync between a checked out copy of a repositorywith another directory.Files that exist in both directories will be copied from thesyncdir to the checkout dir.Files and directories that ARE NOT in the syncdir but are in thecheckout dir will be deleted from subversion.Files and directories that ARE in the syncdir but not in thecheckout dir will be added to subversion.NOTE: This macro does not checkout the files from subversion (dothat prior to calling the macro). In addition, this macrodoes not commit any changes (do that after calling this macro).--><macrodef name="svnsync"><attribute name="checkoutdir" default=".checkout"/> <!-- Keep this as a single directory.If you change to to something else it may not work.--><attribute name="syncdir" default=".release"/> <!-- Points to the new source from dpkg_archive--><sequential><echo message="" file=".svnfileadd.txt"/> <!-- blank out the .svnfileadd.txt file--><echo message="" file=".svndiradd.txt"/> <!-- blank out the .svndiradd.txt file--><echo message="" file=".svndel.txt"/> <!-- blank out the .svndel.txt file--><echo message="" file=".svndeldir.txt"/> <!-- blank out the .svndeldir.txt file--><!--update files in dest that exist in source--><copy todir="@{checkoutdir}" overwrite="true"><fileset dir="@{syncdir}"><present present="both" targetdir="@{checkoutdir}"/></fileset></copy><!-- determine all files in svn that are not in releasethat need to be deleted. Write this information to a file for laterprocessing --><for param="svn.delete"><path><fileset dir="@{checkoutdir}"><present present="srconly" targetdir="@{syncdir}"/></fileset></path><sequential><echo message="@{svn.delete}${line.separator}" file=".svndel.txt" append="true"/></sequential></for><!-- determine all directories in svn that are not in releasethat need to be deleted. Write this information to a file for laterprocessing --><for param="svn.delete"><path><dirset dir="@{checkoutdir}"><present present="srconly" targetdir="@{syncdir}"/></dirset></path><sequential><echo message="@{svn.delete}${line.separator}" file=".svndeldir.txt" append="true"/></sequential></for><!-- load the list of files to delete from subversion into a property.loop through the list calling subversion delete on the files.NOTE: Ensure that the file does contain some files, otherwisethe subversion command will fail. --><loadfile srcFile=".svndel.txt" property="svn.del.list"/><if><not><equals arg1="${svn.del.list}" arg2="$${svn.del.list}"/></not><then><for param="svn.del.file" list="${svn.del.list}" delimiter="${line.separator}"><sequential><echo message="svn delete @{svn.del.file}"/><svn><delete file="@{svn.del.file}"/></svn></sequential></for></then></if><!-- load the list of directories to delete from subversion into a property.loop through the list calling subversion delete on the directories.NOTE: Ensure that the file does contain some files, otherwisethe subversion command will fail. --><loadfile srcFile=".svndeldir.txt" property="svn.del.list"/><if><not><equals arg1="${svn.del.list}" arg2="$${svn.del.list}"/></not><then><for param="svn.del.file" list="${svn.del.list}" delimiter="${line.separator}"><sequential><echo message="svn delete @{svn.del.file}"/><svn><delete dir="@{svn.del.file}"/></svn></sequential></for></then></if><!-- determine all the directories to add source that are not in destand write them to a file for later processing --><for param="svn.add"><path><dirset dir="@{syncdir}"><present present="srconly" targetdir="@{checkoutdir}"/></dirset></path><sequential><echo message="@{svn.add}${line.separator}" file=".svndiradd.txt" append="true"/></sequential></for><!-- determine all the files to add source that are not in destand write them to a file for later processing --><for param="svn.add"><path><fileset dir="@{syncdir}"><present present="srconly" targetdir="@{checkoutdir}"/></fileset></path><sequential><echo message="@{svn.add}${line.separator}" file=".svnfileadd.txt" append="true"/></sequential></for><!-- copy all the files to add source that are not in dest to that whenthe files containing the directories and files to add to subversionadded the files are in the checkout location --><copy todir="@{checkoutdir}"><fileset dir="@{syncdir}"><present present="srconly" targetdir="@{checkoutdir}"/></fileset></copy><!-- fix up the svn add paths to point to the correct directoriesby replacing the syncdir name with the checkout dir name --><replaceregexp file=".svndiradd.txt"match="@{syncdir}"replace="@{checkoutdir}"byline="true"/><!-- fix up the svn add paths to point to the correct filesby replacing the syncdir name with the checkout dir name --><replaceregexp file=".svnfileadd.txt"match="@{syncdir}"replace="@{checkoutdir}"byline="true"/><!-- load the list of directories to add to subversion into aproperty, and then iterate through them performing asubversion add command on each directory.NOTE: Check that there are directories to add, otherwisethe subversion add command will report and error --><loadfile srcFile=".svndiradd.txt" property="svn.dir.add.list"/><if><not><equals arg1="${svn.dir.add.list}" arg2="$${svn.dir.add.list}"/></not><then><for param="svn.dir.add.file" list="${svn.dir.add.list}" delimiter="${line.separator}"><sequential><echo message="svn add @{svn.dir.add.file}"/><svn><add dir="@{svn.dir.add.file}" recurse="false"/></svn></sequential></for></then></if><!-- load the list of files to add to subversion into aproperty, and iterate through them performing asubversion add command on each file.NOTE: Check that there are files to add, otherwisethe subversion add command will report and error --><loadfile srcFile=".svnfileadd.txt" property="svn.file.add.list"/><if><not><equals arg1="${svn.file.add.list}" arg2="$${svn.file.add.list}"/></not><then><for param="svn.file.add.file" list="${svn.file.add.list}" delimiter="${line.separator}"><sequential><echo message="svn add @{svn.file.add.file}"/><svn><add file="@{svn.file.add.file}"/></svn></sequential></for></then></if></sequential></macrodef></project>