| 2067 |
jgill |
1 |
<project name="ant-subversion">
|
|
|
2 |
|
|
|
3 |
<description>
|
|
|
4 |
This ant file requires the use of jars in JavaSVN and svnant.
|
|
|
5 |
|
|
|
6 |
This ant file provides a macro for sync'ing between a subversion
|
|
|
7 |
checkout and another (newer) directory. The idea being that you
|
|
|
8 |
want subversion to look like the sync directory. Refer to the
|
|
|
9 |
documentation above the macrodef for the svnsync macro for more
|
|
|
10 |
information.
|
|
|
11 |
|
|
|
12 |
In addition, this will only work with JavaSVN version
|
|
|
13 |
1.0.4005.cots or later due to the fact that previous versions
|
|
|
14 |
of JavaSVN has a verion number in the svnClientAdapter jar.
|
|
|
15 |
</description>
|
|
|
16 |
|
|
|
17 |
<!-- define the subversion tasks -->
|
|
|
18 |
<taskdef resource="svntask.properties">
|
|
|
19 |
<classpath>
|
|
|
20 |
<pathelement path="${using.JavaSVN.basedir}/jar/javasvn.jar"/>
|
|
|
21 |
<pathelement path="${using.JavaSVN.basedir}/jar/javasvn-javahl.jar"/>
|
| 2069 |
jgill |
22 |
<pathelement path="${using.JavaSVN.basedir}/jar/svnClientAdapter.jar"/>
|
| 2067 |
jgill |
23 |
<pathelement path="${using.svnant.basedir}/jar/svnant.jar"/>
|
|
|
24 |
</classpath>
|
|
|
25 |
</taskdef>
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
<!-- svnsync
|
|
|
29 |
|
|
|
30 |
This macro will sync between a checked out copy of a repository
|
|
|
31 |
with another directory.
|
|
|
32 |
|
|
|
33 |
Files that exist in both directories will be copied from the
|
|
|
34 |
syncdir to the checkout dir.
|
|
|
35 |
|
|
|
36 |
Files and directories that ARE NOT in the syncdir but are in the
|
|
|
37 |
checkout dir will be deleted from subversion.
|
|
|
38 |
|
|
|
39 |
Files and directories that ARE in the syncdir but not in the
|
|
|
40 |
checkout dir will be added to subversion.
|
|
|
41 |
|
|
|
42 |
NOTE: This macro does not checkout the files from subversion (do
|
|
|
43 |
that prior to calling the macro). In addition, this macro
|
|
|
44 |
does not commit any changes (do that after calling this macro).
|
|
|
45 |
-->
|
|
|
46 |
<macrodef name="svnsync">
|
|
|
47 |
<attribute name="checkoutdir" default=".checkout"/> <!-- Keep this as a single directory.
|
|
|
48 |
If you change to to something else it may not work.-->
|
|
|
49 |
<attribute name="syncdir" default=".release"/> <!-- Points to the new source from dpkg_archive-->
|
|
|
50 |
|
|
|
51 |
<sequential>
|
|
|
52 |
<echo message="" file=".svnfileadd.txt"/> <!-- blank out the .svnfileadd.txt file-->
|
|
|
53 |
<echo message="" file=".svndiradd.txt"/> <!-- blank out the .svndiradd.txt file-->
|
|
|
54 |
<echo message="" file=".svndel.txt"/> <!-- blank out the .svndel.txt file-->
|
|
|
55 |
<echo message="" file=".svndeldir.txt"/> <!-- blank out the .svndeldir.txt file-->
|
|
|
56 |
|
|
|
57 |
<!--update files in dest that exist in source-->
|
|
|
58 |
<copy todir="@{checkoutdir}" overwrite="true">
|
|
|
59 |
<fileset dir="@{syncdir}">
|
|
|
60 |
<present present="both" targetdir="@{checkoutdir}"/>
|
|
|
61 |
</fileset>
|
|
|
62 |
</copy>
|
|
|
63 |
|
|
|
64 |
<!-- determine all files in svn that are not in release
|
|
|
65 |
that need to be deleted. Write this information to a file for later
|
|
|
66 |
processing -->
|
|
|
67 |
<for param="svn.delete">
|
|
|
68 |
<path>
|
|
|
69 |
<fileset dir="@{checkoutdir}">
|
|
|
70 |
<present present="srconly" targetdir="@{syncdir}"/>
|
|
|
71 |
</fileset>
|
|
|
72 |
</path>
|
|
|
73 |
<sequential>
|
|
|
74 |
<echo message="@{svn.delete}${line.separator}" file=".svndel.txt" append="true"/>
|
|
|
75 |
</sequential>
|
|
|
76 |
</for>
|
|
|
77 |
|
|
|
78 |
<!-- determine all directories in svn that are not in release
|
|
|
79 |
that need to be deleted. Write this information to a file for later
|
|
|
80 |
processing -->
|
|
|
81 |
<for param="svn.delete">
|
|
|
82 |
<path>
|
|
|
83 |
<dirset dir="@{checkoutdir}">
|
|
|
84 |
<present present="srconly" targetdir="@{syncdir}"/>
|
|
|
85 |
</dirset>
|
|
|
86 |
</path>
|
|
|
87 |
<sequential>
|
|
|
88 |
<echo message="@{svn.delete}${line.separator}" file=".svndeldir.txt" append="true"/>
|
|
|
89 |
</sequential>
|
|
|
90 |
</for>
|
|
|
91 |
|
|
|
92 |
<!-- load the list of files to delete from subversion into a property.
|
|
|
93 |
loop through the list calling subversion delete on the files.
|
|
|
94 |
|
|
|
95 |
NOTE: Ensure that the file does contain some files, otherwise
|
|
|
96 |
the subversion command will fail. -->
|
|
|
97 |
<loadfile srcFile=".svndel.txt" property="svn.del.list"/>
|
|
|
98 |
<if>
|
|
|
99 |
<not>
|
|
|
100 |
<equals arg1="${svn.del.list}" arg2="$${svn.del.list}"/>
|
|
|
101 |
</not>
|
|
|
102 |
<then>
|
|
|
103 |
<for param="svn.del.file" list="${svn.del.list}" delimiter="${line.separator}">
|
|
|
104 |
<sequential>
|
|
|
105 |
<echo message="svn delete @{svn.del.file}"/>
|
|
|
106 |
<svn>
|
|
|
107 |
<delete file="@{svn.del.file}"/>
|
|
|
108 |
</svn>
|
|
|
109 |
</sequential>
|
|
|
110 |
</for>
|
|
|
111 |
</then>
|
|
|
112 |
</if>
|
|
|
113 |
|
|
|
114 |
<!-- load the list of directories to delete from subversion into a property.
|
|
|
115 |
loop through the list calling subversion delete on the directories.
|
|
|
116 |
|
|
|
117 |
NOTE: Ensure that the file does contain some files, otherwise
|
|
|
118 |
the subversion command will fail. -->
|
|
|
119 |
<loadfile srcFile=".svndeldir.txt" property="svn.del.list"/>
|
|
|
120 |
<if>
|
|
|
121 |
<not>
|
|
|
122 |
<equals arg1="${svn.del.list}" arg2="$${svn.del.list}"/>
|
|
|
123 |
</not>
|
|
|
124 |
<then>
|
|
|
125 |
<for param="svn.del.file" list="${svn.del.list}" delimiter="${line.separator}">
|
|
|
126 |
<sequential>
|
|
|
127 |
<echo message="svn delete @{svn.del.file}"/>
|
|
|
128 |
<svn>
|
|
|
129 |
<delete dir="@{svn.del.file}"/>
|
|
|
130 |
</svn>
|
|
|
131 |
</sequential>
|
|
|
132 |
</for>
|
|
|
133 |
</then>
|
|
|
134 |
</if>
|
|
|
135 |
|
|
|
136 |
<!-- determine all the directories to add source that are not in dest
|
|
|
137 |
and write them to a file for later processing -->
|
|
|
138 |
<for param="svn.add">
|
|
|
139 |
<path>
|
|
|
140 |
<dirset dir="@{syncdir}">
|
|
|
141 |
<present present="srconly" targetdir="@{checkoutdir}"/>
|
|
|
142 |
</dirset>
|
|
|
143 |
</path>
|
|
|
144 |
<sequential>
|
|
|
145 |
<echo message="@{svn.add}${line.separator}" file=".svndiradd.txt" append="true"/>
|
|
|
146 |
</sequential>
|
|
|
147 |
</for>
|
|
|
148 |
|
|
|
149 |
<!-- determine all the files to add source that are not in dest
|
|
|
150 |
and write them to a file for later processing -->
|
|
|
151 |
<for param="svn.add">
|
|
|
152 |
<path>
|
|
|
153 |
<fileset dir="@{syncdir}">
|
|
|
154 |
<present present="srconly" targetdir="@{checkoutdir}"/>
|
|
|
155 |
</fileset>
|
|
|
156 |
</path>
|
|
|
157 |
<sequential>
|
|
|
158 |
<echo message="@{svn.add}${line.separator}" file=".svnfileadd.txt" append="true"/>
|
|
|
159 |
</sequential>
|
|
|
160 |
</for>
|
|
|
161 |
|
|
|
162 |
<!-- copy all the files to add source that are not in dest to that when
|
|
|
163 |
the files containing the directories and files to add to subversion
|
|
|
164 |
added the files are in the checkout location -->
|
|
|
165 |
<copy todir="@{checkoutdir}">
|
|
|
166 |
<fileset dir="@{syncdir}">
|
|
|
167 |
<present present="srconly" targetdir="@{checkoutdir}"/>
|
|
|
168 |
</fileset>
|
|
|
169 |
</copy>
|
|
|
170 |
|
|
|
171 |
<!-- fix up the svn add paths to point to the correct directories
|
|
|
172 |
by replacing the syncdir name with the checkout dir name -->
|
|
|
173 |
<replaceregexp file=".svndiradd.txt"
|
|
|
174 |
match="@{syncdir}"
|
|
|
175 |
replace="@{checkoutdir}"
|
|
|
176 |
byline="true"/>
|
|
|
177 |
<!-- fix up the svn add paths to point to the correct files
|
|
|
178 |
by replacing the syncdir name with the checkout dir name -->
|
|
|
179 |
<replaceregexp file=".svnfileadd.txt"
|
|
|
180 |
match="@{syncdir}"
|
|
|
181 |
replace="@{checkoutdir}"
|
|
|
182 |
byline="true"/>
|
|
|
183 |
|
|
|
184 |
<!-- load the list of directories to add to subversion into a
|
|
|
185 |
property, and then iterate through them performing a
|
|
|
186 |
subversion add command on each directory.
|
|
|
187 |
|
|
|
188 |
NOTE: Check that there are directories to add, otherwise
|
|
|
189 |
the subversion add command will report and error -->
|
|
|
190 |
<loadfile srcFile=".svndiradd.txt" property="svn.dir.add.list"/>
|
|
|
191 |
<if>
|
|
|
192 |
<not>
|
|
|
193 |
<equals arg1="${svn.dir.add.list}" arg2="$${svn.dir.add.list}"/>
|
|
|
194 |
</not>
|
|
|
195 |
<then>
|
|
|
196 |
<for param="svn.dir.add.file" list="${svn.dir.add.list}" delimiter="${line.separator}">
|
|
|
197 |
<sequential>
|
|
|
198 |
<echo message="svn add @{svn.dir.add.file}"/>
|
|
|
199 |
<svn>
|
|
|
200 |
<add dir="@{svn.dir.add.file}" recurse="false"/>
|
|
|
201 |
</svn>
|
|
|
202 |
</sequential>
|
|
|
203 |
</for>
|
|
|
204 |
</then>
|
|
|
205 |
</if>
|
|
|
206 |
|
|
|
207 |
<!-- load the list of files to add to subversion into a
|
|
|
208 |
property, and iterate through them performing a
|
|
|
209 |
subversion add command on each file.
|
|
|
210 |
|
|
|
211 |
NOTE: Check that there are files to add, otherwise
|
|
|
212 |
the subversion add command will report and error -->
|
|
|
213 |
<loadfile srcFile=".svnfileadd.txt" property="svn.file.add.list"/>
|
|
|
214 |
<if>
|
|
|
215 |
<not>
|
|
|
216 |
<equals arg1="${svn.file.add.list}" arg2="$${svn.file.add.list}"/>
|
|
|
217 |
</not>
|
|
|
218 |
<then>
|
|
|
219 |
<for param="svn.file.add.file" list="${svn.file.add.list}" delimiter="${line.separator}">
|
|
|
220 |
<sequential>
|
|
|
221 |
<echo message="svn add @{svn.file.add.file}"/>
|
|
|
222 |
<svn>
|
|
|
223 |
<add file="@{svn.file.add.file}"/>
|
|
|
224 |
</svn>
|
|
|
225 |
</sequential>
|
|
|
226 |
</for>
|
|
|
227 |
</then>
|
|
|
228 |
</if>
|
|
|
229 |
</sequential>
|
|
|
230 |
</macrodef>
|
|
|
231 |
|
|
|
232 |
</project>
|