forked from mxunit/mxunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
494 lines (424 loc) · 18.6 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<?xml version="1.0"?>
<project name="MXUnit Framework Build" default="package" basedir=".">
<description>
Build file for moving all files into a directory structure easily zippable and deployable
</description>
<!--
Committers: HOW TO CONFIGURE YOUR ENVIRONMENT
1) (one time only): get latest from repository to ensure you have all jar files from the lib directory
2) add the commons-net, jakarta-oro, mail, and activation jars to your ant classpath in eclipse (window - preferences - ant - runtime - add external jars)
3) in windows explorer, navigate to your eclipse/plugins directory. there should be an org.tigris.subversion.... directory.
mine is at C:\eclipse_33_rcp\plugins\org.tigris.subversion.javahl.win32_1.2.4
find that directory and copy the entire directory path. Now, go to your computer's path variable (my computer - properties - advanced - environment variables - path) and paste that path as an extra entry
4) You will probably have to restart your computer after that. Every time I've tried just restarting eclipse, it didn't work.
5) when you got latest, it put a directory called "buildprops" into your mxunit directory. get the unames.properties file from marc and put it in there. otherwise, this build will not work at all. nothing. nada.
-->
<!--
================================================
Intended Targets
================================================
-->
<!--
=================================
Target: publish
- publish the zip
- upload to google code
- upload version.properties to the website
- reload the website
=================================
-->
<target name="publish" depends="runTests,incrementVersion,package,upload,updatewebsite,publishTestResults" description="--> packages into a zip and uploads to google code" />
<!--
=================================
Target: package
Generates the zip archive
=================================
-->
<target name="package" depends="clean,version,genApiDocs" description="--> packages the appropriate files into the deployment-ready zip file. use this for testing; otherwise, use publish">
<echo message="building ${zipfile}. basedir is ${basedir}" />
<zip destfile="${zipfile}" casesensitive="false">
<zipfileset dir="${basedir}" includes="*.*,ant/,buildprops/,eclipse/,doc/,framework/,generator/,images/,PluginDemoTests/,resources/,runner/,samples/,tests/,lib/ant-contrib**" excludes=".settings/,.git/,.gitignore,MXUnitInstallTest.cfc,**/testresults/,**/stats/,**/junithtml/,.project,.deployment,**/unames.properties,tests/tmp/,ftp.listing,**/*.db,**/copysnippets.properties,**/copydictionary**,**/*.bak,buildprops/nightlyversion.properties,settings.xml,README.html,README.textile,README-toc.xml" prefix="mxunit" casesensitive="false" />
</zip>
</target>
<!--
=================================
Target: packageNightly
Generates the zip archive
=================================
-->
<target name="packageNightly" depends="package">
<move file="${zipfile}" tofile="${nightlyfile}" overwrite="true"/>
<copy file="${version.file}" tofile="${version.nightlyfile}" overwrite="true"/>
<copy file="${readme.file}" tofile="${readme.nightlyfile}" overwrite="true"/>
<propertyfile file="${version.nightlyfile}" comment="Build version info">
<entry key="build.date" type="date" value="now" pattern="MM/dd/yyyy" />
<entry key="build.versiondescription" operation="=" value="Nightly Build" />
<entry key="build.buildnum" type="int" operation="+" value="1" />
</propertyfile>
<replaceregexp file="${readme.nightlyfile}" match="Version Info:(.*)" replace="Version Info: This is nightly build version ${build.version}, built on ${nightlydate}" />
<zip file="${nightlyfile}" update="true">
<zipfileset dir="." includes="${version.nightlyfile}" fullpath="mxunit/buildprops/version.properties"/>
<zipfileset dir="." includes="${readme.nightlyfile}" fullpath="mxunit/README.txt"/>
</zip>
<delete file="${readme.nightlyfile}"/>
</target>
<!--
================================================
Internal Targets
Run these individually for testing only
================================================
-->
<!--
=================================
Target: init
Initializes the general settings and properties used in the build
=================================
-->
<target name="init">
<tstamp>
<format pattern="MM_dd_yyyy" property="nightlystamp" />
<format pattern="MM/dd/yyyy" property="nightlydate" />
</tstamp>
<property name="dist" location="dist" />
<property name="nightlyfile" location="dist/mxunit-nightly-${nightlystamp}.zip" />
<property name="unames.file" value="buildprops/unames.properties" />
<property name="version.file" value="buildprops/version.properties" />
<property name="version.nightlyfile" value="buildprops/nightlyversion.properties" />
<property name="readme.file" value="README.txt" />
<property name="readme.nightlyfile" value="README.nightly" />
<property name="antrunner.file" value="buildprops/antrunner.properties" />
<property name="testmailmessage.file" value="buildprops/testresultsmail.html" />
<!-- user property file for instance specific settings -->
<property file="${unames.file}" />
<!--
get the server, port, and webroot properties from the
antrunner file; this way each developer can have their
own version of the properties file with different
values depending on their setup
-->
<property file="${antrunner.file}" />
<!-- for the test runner -->
<property name="mxunit.jar" value="ant/lib/mxunit-ant.jar" />
<property name="junit.out.dir.xml" value="tests/testresults/${server}_${port}" />
<property name="junit.out.dir.html" value="${junit.out.dir.xml}/html" />
<property name="output.dir" value="${junit.out.dir.xml}/tmp" />
<property name="style.dir" value="ant/xsl/" />
<path id="project.classpath">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask" classpath="${mxunit.jar}" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="project.classpath" />
</target>
<!--
=================================
Target: clean
Cleans up un-needed files
=================================
-->
<target name="clean" depends="init">
<mkdir dir="${dist}" />
<delete failonerror="false">
<fileset dir="${dist}" includes="*.zip" />
</delete>
<delete failonerror="false">
<fileset dir="framework/generated" includes="*.*" />
</delete>
</target>
<!--
=================================
Target: incrementVersion
Increments the version for the next build
=================================
-->
<target name="incrementVersion" depends="init">
<!--
<svn username="${gc.username}" password="${gc.password}" svnkit="true">
<update dir="buildprops" />
</svn>
-->
<propertyfile file="${version.file}" comment="Build version info">
<entry key="build.date" type="date" value="now" pattern="MM/dd/yyyy" />
<entry key="build.major" type="int" operation="=" value="2" />
<entry key="build.minor" type="int" operation="=" value="0" />
<entry key="build.notation" operation="=" value="" />
<entry key="build.versiondescription" operation="=" value="Release" />
<!-- this is autoincremented -->
<entry key="build.buildnum" type="int" operation="+" value="1" />
</propertyfile>
<!--
<svn username="${gc.username}" password="${gc.password}" svnkit="true">
<commit dir="buildprops" message="" />
</svn>
-->
<property file="${version.file}" />
<echoproperties prefix="build" />
</target>
<!--
=================================
Target: version
Creates the zip file for the current version
=================================
-->
<target name="version" depends="init">
<property file="${version.file}" />
<property name="build.version" value="${build.major}.${build.minor}.${build.buildnum}${build.notation}" />
<property name="zipfile" location="${dist}${file.separator}mxunit-${build.version}.zip" />
<echo message="build.version is ${build.version} -- zipfile is ${zipfile}" />
<replaceregexp file="${readme.file}" match="Version Info:(.*)" replace="Version Info: This is release build ${build.version}, built on ${build.date}" />
</target>
<!--
=================================
Target: upload
Uploads the release zip to the Google Code site
=================================
-->
<target name="upload" depends="version">
<input message="Please add a summary for this version" addproperty="build.summary" defaultvalue="MXUnit Unit Test Framework version ${build.version}" />
<taskdef classname="net.bluecow.googlecode.ant.GoogleCodeUploadTask" classpathref="project.classpath" name="gcupload" />
<gcupload username="${gc.username}" password="${gc.password}" projectname="mxunit" filename="${zipfile}" targetfilename="mxunit-${build.version}.zip" summary="${build.summary}" />
</target>
<!--
=================================
Target: updatewebsite
Updates the version on the website
=================================
-->
<target name="updatewebsite" depends="version">
<!-- ftp the version file to the website and reinit the application -->
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" remotedir="">
<fileset dir="buildprops">
<include name="version.properties" />
</fileset>
</ftp>
<!-- reinit the web app; this causes the version.properties file to be reread into the application scope -->
<loadresource property="homepage">
<!--${http.reinit} undefined: to do: talk to marc -->
<url url="http://mxunit.org/index.cfm?reinit=true" />
</loadresource>
</target>
<!--
=================================
Target: tagVersion
! intended for use by publish only !
Creates an svn tag from the trunk
=================================
<target name="tagVersion" depends="init,version">
<svn username="${gc.username}" password="${gc.password}" svnkit="true">
<copy srcURL="${svnserver}/mxunit/trunk" destURL="${svnserver}/mxunit/tags/${build.version}" message="autotagging version ${build.version}" />
</svn>
</target>
-->
<!--
=================================
Target: update
Updates the svn to the latest version
=================================
<target name="update" depends="init" unless="nosvnupdate">
<svn username="${gc.username}" password="${gc.password}" svnkit="true">
<update dir="." />
</svn>
</target>
-->
<!--
=================================
Target: runTests
Runs the MXUnit tests on MXUnit
=================================
-->
<target name="runTests" depends="init">
<!--
load the current version of the package-summary file;
this way, we can put it at the end of the email we
send so that comparing test the aggregate test results
is easy; makes it simpler to see if any test failures
crept in
-->
<loadfile property="currentresultshtml" srcFile="${junit.out.dir.html}/mxunit/tests/package-summary.html" failonerror="false" />
<delete dir="${junit.out.dir.html}" />
<delete dir="${output.dir}" />
<mkdir dir="${junit.out.dir.html}" />
<mkdir dir="${output.dir}" />
<property name="context" value="" />
<mxunittask server="${server}" port="${port}" defaultrunner="${context}/mxunit/runner/HttpAntRunner.cfc" outputdir="${output.dir}" verbose="true" testResultsSummary="my.summary" failureproperty="testsfailed">
<!-- componentPath is not required, but it results in a much faster test run -->
<directory remoteMethod="run" path="${webroot}/mxunit/tests/framework/" packageName="mxunit.tests.framework" componentPath="mxunit.tests.framework" recurse="false" includes="*.cfc" excludes="" />
<directory remoteMethod="run" path="${webroot}/mxunit/tests/mightymock/" packageName="mxunit.tests.mightymock" componentPath="mxunit.tests.mightymock" recurse="false" includes="*.cfc" excludes="" />
<directory remoteMethod="run" path="${webroot}/mxunit/tests/runner" packageName="mxunit.tests.runner" componentPath="mxunit.tests.runner" recurse="false" includes="*.cfc" excludes="" />
</mxunittask>
<!-- create nice pretty report -->
<junitreport todir="${junit.out.dir.html}">
<fileset dir="${output.dir}">
<include name="*.xml" />
</fileset>
<report format="frames" todir="${junit.out.dir.html}" styledir="${style.dir}" />
</junitreport>
<!-- Read the properties files we generated
<property file="${output.dir}/my.summary" />
<echoproperties />
-->
<!--
load the version we just created; this will be the first
set of results in the email we send
-->
<loadfile property="resultshtml" srcFile="${junit.out.dir.html}/mxunit/tests/package-summary.html" />
<loadfile property="resultscss" srcFile="${junit.out.dir.html}/stylesheet.css" />
<!--
<if>
<isset property="mail.ssl" />
<then>
<mail from="${mail.from}" tolist="${mail.to}" mailhost="${mail.host}" subject="MXUnit Build Results" charset="UTF-8" messagemimetype="text/html" user="${mail.user}" password="${mail.password}" ssl="${mail.ssl}" mailport="${mail.port}" messagefile="${testmailmessage.file}" failonerror="false" />
</then>
<else>
<mail from="${mail.from}" tolist="${mail.to}" mailhost="${mail.host}" subject="MXUnit Build Results" charset="UTF-8" messagemimetype="text/html" messagefile="${testmailmessage.file}" failonerror="false" />
</else>
</if>
-->
<fail if="testsfailed" message="Failing the build because tests failed" />
</target>
<!--
=================================
Target: genApiDocs
Calls JS in build props which invokes the ColdDoc cfml script
=================================
-->
<target name="genApiDocs" depends="init">
<delete dir="doc/api" failonerror="false"/>
<mkdir dir="doc/api" />
<script language="javascript" src="buildprops/scripts/http_doc_gen.js" />
</target>
<!--
=================================
Target: publishTestResults
FTPs the test results to the web server
=================================
-->
<target name="publishTestResults" depends="init">
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" remotedir="testresults">
<fileset dir="${junit.out.dir.html}">
<include name="**/*" />
</fileset>
</ftp>
</target>
<!--
=================================
Target: publishNightlyBuild
FTPs the nightly build to the web server
=================================
-->
<target name="publishNightly" depends="runTests,packageNightly,publishTestResults">
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" action="del">
<fileset>
<include name="nightly/mxunit-nightly*.zip" />
</fileset>
</ftp>
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" remotedir="nightly">
<fileset dir="dist">
<include name="mxunit-nightly*" />
</fileset>
</ftp>
</target>
<!--
=================================
Target: testFTP
Tests the FTP connection by uploading a file
=================================
-->
<target name="testFTP" depends="init">
<ftp server="${ftp.site}" userid="${ftp.username}" password="${ftp.password}" action="list" listing="ftp.listing" verbose="true">
<fileset>
<include name="index.html" />
</fileset>
</ftp>
</target>
<!--
=================================
Target: testMail
Tests the mail sending ability
=================================
-->
<target name="testMail" depends="init">
<if>
<isset property="mail.ssl" />
<then>
<mail from="${mail.from}" tolist="${mail.to}" mailhost="${mail.host}" subject="MXUnit Build Results" charset="UTF-8" messagemimetype="text/html" user="${mail.user}" password="${mail.password}" ssl="${mail.ssl}" mailport="${mail.port}" message="<h1>Test Successful</h1>" />
</then>
<else>
<mail from="${mail.from}" tolist="${mail.to}" mailhost="${mail.host}" subject="MXUnit Build Results" charset="UTF-8" messagemimetype="text/html" message="<h1>Test Successful</h1>" />
</else>
</if>
</target>
<!--
=================================
Target: compileCheck
Compiles the ColdFusion files for any syntax errors
Only works on Windows with ColdFusion
=================================
-->
<target name="compileCheck" depends="init">
<echo>Check Coldfusion Compile for ${webroot}</echo>
<!-- TODO: add os check and run for linux -->
<exec failonerror="true" dir="${cfcompile_path}" executable="cmd.exe" output="${webroot}\compile.log">
<env key="JAVA_HOME" value="${JAVA_HOME}" />
<arg line="/c cfcompile.bat ${webroot}" />
</exec>
<!-- check log for failures -->
<loadfile srcfile="${webroot}compile.log" property="src.file.cferrors">
<filterchain>
<LineContainsRegExp>
<regexp pattern="Error*" />
</LineContainsRegExp>
<trim />
</filterchain>
</loadfile>
<!-- will be set if errors found else variable will be unset -->
<echo>${src.file.cferrors}</echo>
<fail message="cfcompile violation is found.">
<condition>
<isset property="src.file.cferrors" />
</condition>
</fail>
<echo>Successful ColdFusion Compile</echo>
</target>
<!--
=================================
Target: varScopeCheck
Checks the CFC files for any unscoped variables
=================================
-->
<target name="varScopeCheck" depends="init">
<!-- MUST HAVE VARSCOPER IN WEBROOT -->
<!-- not sure if we want to put the jar in the lib folder -->
<echo>Check for unscoped variables</echo>
<!-- load the varScoper task -->
<taskdef name="conGet" classname="com.varscoper.ant.task.ConditionalGet" classpathref="project.classpath" />
<property name="filePathToUse" value="${webroot}" />
<property name="recursiveDirectory" value="true" />
<conGet dest="varScoper.csv" url="http://${server}:${port}/varscoper/varScoper.cfm">
<parameter name="filePath" value="${filePathToUse}" />
<parameter name="displayFormat" value="csv" />
<parameter name="recursiveDirectory" value="${recursiveDirectory}" />
<!--
<FailIfNotFound pattern="<results></results>" />
<FailIfFound pattern=".cfc" message="var scope violation is found." />
<FailIfFound pattern=".cfm" message="var scope violation is found." />
-->
</conGet>
<!-- check csv file for any violations -->
<loadfile srcfile="varScoper.csv" property="varScoper.cvs">
<filterchain>
<headfilter skip="1" />
<trim />
</filterchain>
</loadfile>
<!-- will be set if violations found else variable will be unset -->
<echo>${varScoper.cvs}</echo>
<fail message="var scope violation is found.">
<condition>
<isset property="varScoper.cvs" />
</condition>
</fail>
<echo>Successful check for unscoped variables</echo>
</target>
</project>