-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
380 lines (315 loc) · 14.3 KB
/
Copy pathbuild.xml
File metadata and controls
380 lines (315 loc) · 14.3 KB
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
<?xml version="1.0"?>
<project name="middleman" default="build" basedir=".">
<property environment="env"/>
<property name="env.COMPUTERNAME" value="${env.HOSTNAME}"/>
<!-- Set the os property -->
<condition property="isLinux">
<os family="unix" />
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isMac">
<os family="mac" />
</condition>
<condition property="os.classifier" value="win">
<os family="windows" />
</condition>
<condition property="os.classifier" value="mac">
<os family="mac" />
</condition>
<condition property="os.classifier" value="linux">
<os family="unix" />
</condition>
<property name="os.classifier" value="unsupported" />
<echo message="This the build file for: ${ant.project.name}"/>
<echo message="Using Ant (version ${ant.version}) found in: ${ant.home}"/>
<echo message="with Java (version ${ant.java.version}) found in ${java.home}"/>
<tstamp>
<format property="build.timestamp" pattern="yyyyMMdd'T'HHmmss.SSS"/>
</tstamp>
<!-- properties overridden by cruisecontrol -->
<property name="release.label" value="Dev"/>
<property name="src.dir" location="src"/>
<property name="test.dir" location="test"/>
<property name="firefoxProfile.dir" location="${test.dir}/middleman/firefoxprofile"/>
<property name="build.dir" location="build"/>
<property name="dist.dir" value="${build.dir}/dist/middleman"/>
<property name="compiled.jar.dir" location="${build.dir}/jar"/>
<property name="manifest.file" value="${compiled.jar.dir}/MANIFEST.MF"/>
<property name="test.reports.dir" location="${build.dir}/test-reports"/>
<property name="reports.dir" location="${build.dir}/reports"/>
<property name="instrumented.dir" value="${build.dir}/instrumented"/>
<property name="findbugs.home" value="${basedir}/tools/findbugs-1.3.8"/>
<property name="cobertura.dir" value="${basedir}/tools/cobertura-1.9.2"/>
<property name="svnant.dir" value="${basedir}/tools/svnant"/>
<path id="classpath">
<fileset dir="lib">
<include name="build/*.jar"/>
<include name="release/*.jar"/>
</fileset>
</path>
<path id="test.classpath">
<fileset dir="${compiled.jar.dir}" includes="*.jar"/>
<fileset dir="lib">
<include name="test/*.jar"/>
</fileset>
<path refid="classpath"/>
</path>
<path id="antlr.classpath">
<fileset dir="${basedir}/lib/build">
<include name="*.jar"/>
</fileset>
</path>
<path id="svnant.classpath">
<fileset dir="${svnant.dir}/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="cobertura.class.path">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar"/>
<include name="lib/**/*.jar"/>
</fileset>
</path>
<taskdef classpathref="cobertura.class.path" resource="tasks.properties"/>
<typedef classpathref="svnant.classpath" resource="org/tigris/subversion/svnant/svnantlib.xml"/>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath>
<fileset dir="${findbugs.home}/lib" includes="*.jar"/>
</classpath>
</taskdef>
<macrodef name="compile.source">
<attribute name="src.dir"/>
<attribute name="dest.dir"/>
<attribute name="jar.name"/>
<attribute name="manifest"/>
<attribute name="classes.dir" default="@{dest.dir}/classes"/>
<attribute name="classpathref" default="classpath"/>
<attribute name="debug" default="yes"/>
<sequential>
<mkdir dir="@{dest.dir}"/>
<mkdir dir="@{classes.dir}"/>
<javac includeantruntime="false" srcdir="@{src.dir}" destdir="@{classes.dir}" classpathref="@{classpathref}" debug="@{debug}"
target="1.6"/>
<copy todir="@{classes.dir}" includeemptydirs="no">
<fileset dir="@{src.dir}" excludes="**/*.java"/>
</copy>
<jar destfile="@{dest.dir}/@{jar.name}" basedir="@{classes.dir}">
<manifest>
<attribute name="Main-Class" value="middleman.Console"/>
<!--<attribute name="SVN-URL" value="${svn.url}"/>
<attribute name="SVN-Revision" value="${svn.revision}"/>-->
<attribute name="GIT-Revision" value="${git.tag}"/>
<attribute name="GIT-Repo" value="${git.url}"/>
</manifest>
<fileset dir="view" includes="**/**/*"/>
</jar>
<delete dir="@{classes.dir}"/>
</sequential>
</macrodef>
<macrodef name="unit.test">
<attribute name="test.dir"/>
<sequential>
<mkdir dir="${test.reports.dir}"/>
<junit fork="yes" forkmode="once" failureproperty="test.failure" logfailedtests="yes" printsummary="on">
<!-- **additional attributes for output to debug **
showoutput="true" enabletestlistenerevents="true" -->
<jvmarg value="-Xmx512M"/>
<classpath>
<fileset dir="${instrumented.dir}" includes="*.jar"/>
<path refid="test.classpath"/>
<path refid="cobertura.class.path"/>
</classpath>
<formatter type="xml"/>
<sysproperty key="net.sourceforge.cobertura.datafile" file="${build.dir}/cobertura.ser"/>
<batchtest todir="${test.reports.dir}" if="testcase">
<fileset dir="@{test.dir}">
<include name="**/${testcase}.java"/>
</fileset>
</batchtest>
<batchtest todir="${test.reports.dir}" unless="testcase">
<fileset dir="@{test.dir}">
<include name="**/*Tests.java"/>
</fileset>
</batchtest>
</junit>
<fail message="Test(s) failed" if="test.failure"/>
<echo message="Test(s) passed"/>
</sequential>
</macrodef>
<!-- Targets -->
<!-- Check if Antlr is in classpath -->
<target name="antlr_classpath">
<whichresource property="antlr.in.classpath" class="org.antlr.Tool" />
<fail message="Antlr3 library not found via CLASSPATH ${java.class.path}">
<condition>
<not>
<isset property="antlr.in.classpath"/>
</not>
</condition>
</fail>
<echo>Antlr3 found via CLASSPATH</echo>
</target>
<target name="generate.parser" description="Generates the lexer, parser and tree-walker from the grammar files.">
<echo>Generating the lexer and parser...</echo>
<java classname="org.antlr.Tool" fork="true" failonerror="true">
<arg value="-fo" />
<arg value="${main.src.dir}/${parser.package}" />
<arg value="${parser.grammar.file}" />
<classpath refid="classpath" />
</java>
</target>
<target name="compile.grammar" depends="antlr_classpath, clean.grammar">
<antlr:ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr"
report="true"
target="src/middleman/configuration/Configuration.g"
outputdirectory="src/middleman/configuration">
<classpath refid="antlr.classpath"/>
</antlr:ant-antlr3>
</target>
<target name="build" depends="clean, compile.grammar, compile, grammar.test, test, dist"
description="Runs the full build"/>
<condition property="build.dir.exists" else="false">
<available file="${build.dir}" type="dir" />
</condition>
<target name="clean" description="Deletes all the build directories." if="build.dir.exists">
<delete dir="${build.dir}" failonerror="false"/>
</target>
<target name="clean.grammar" description="Deletes the Antlr3 generated configuration lexer and parser.">
<delete file="src/middleman/configuration/ConfigurationLexer.java"/>
<delete file="src/middleman/configuration/ConfigurationParser.java"/>
</target>
<target name="grammar.test" depends="compile.grammar">
<java classname="org.antlr.gunit.Interp" failonerror="true">
<classpath refid="test.classpath"/>
<arg value="${basedir}/test/Configuration.gunit"/>
</java>
</target>
<target name="compile" depends="git.info, compile.grammar" description="Compiles the source">
<mkdir dir="${compiled.jar.dir}"/>
<manifest file="${manifest.file}" description="The manifest file that will be generated as part of the build" >
<attribute name="Built-By" value="${user.name}"/>
<section name="middleman">
<attribute name="Specification-Title" value="${ant.project.name} web application"/>
<attribute name="Specification-Version" value="${release.label}"/>
<attribute name="Specification-Vendor" value=""/>
<attribute name="Implementation-Title" value="common"/>
<attribute name="Implementation-Version" value="${release.label}"/>
<attribute name="Implementation-Vendor" value="Copyright © 2009 Graham Brooks"/>
<attribute name="GIT-Revision" value="${git.tag}"/>
<attribute name="GIT-Repo" value="${git.url}"/>
</section>
</manifest>
<compile.source src.dir="${src.dir}" dest.dir="${compiled.jar.dir}"
jar.name="${ant.project.name}.jar" manifest="${manifest.file}"/>
<compile.source src.dir="${test.dir}" dest.dir="${compiled.jar.dir}"
jar.name="${ant.project.name}.test.jar" manifest="${manifest.file}"
classpathref="test.classpath"/>
</target>
<condition property="firefoxProfile.dir.exists">
<available file="${firefoxProfile.dir}" type="dir" />
</condition>
<target name="test.firefoxProfile.dir" description="Create Firefix profile directory if doesnt exist (Travis)" unless="firefoxProfile.dir.exists">
<echo>Creating Firefix profile directory as it doesnt exist (Travis!)</echo>
<mkdir dir="${firefoxProfile.dir}"/>
</target>
<target name="test" description="Runs JUnit tests (without building)" unless="notests" depends="test.firefoxProfile.dir">
<mkdir dir="${instrumented.dir}"/>
<unit.test test.dir="${test.dir}"/>
</target>
<target name="dist" description="Create a release distribution (zip)." depends="compile">
<mkdir dir="${dist.dir}"/>
<copy todir="${dist.dir}/lib">
<fileset dir="lib/release" includes="*.jar"/>
<fileset file="${compiled.jar.dir}/middleman.jar"/>
</copy>
<copy todir="${dist.dir}">
<fileset dir="docs" includes="*"/>
</copy>
<chmod file="${dist.dir}/middleman.sh" perm="ugo+rx"/>
<zip destfile="${build.dir}/middleman.zip" comment="Middleman distribution">
<fileset dir="${build.dir}/dist" includes="**/*"/>
</zip>
</target>
<target name="instrument" depends="compile.grammar, compile, grammar.test">
<mkdir dir="${instrumented.dir}"/>
<cobertura-instrument todir="${instrumented.dir}" datafile="${build.dir}/cobertura.ser">
<fileset dir="${compiled.jar.dir}">
<include name="middleman.jar"/>
</fileset>
</cobertura-instrument>
</target>
<target name="coverage" depends="instrument, test">
<cobertura-report format="html" destdir="${reports.dir}/html/cobertura"
datafile="${build.dir}/cobertura.ser">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</cobertura-report>
<cobertura-report format="xml" destdir="${reports.dir}/xml/cobertura"
datafile="${build.dir}/cobertura.ser">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</cobertura-report>
</target>
<target name="findbugs" depends="compile">
<mkdir dir="${reports.dir}/xml"/>
<findbugs home="${findbugs.home}"
failOnError="true"
output="xml"
outputFile="${reports.dir}/xml/findbugs.xml">
<auxClasspath>
<path refid="test.classpath"/>
</auxClasspath>
<sourcePath path="${basedir}/src/"/>
<class location="${compiled.jar.dir}/middleman.jar"/>
</findbugs>
</target>
<target name="ci" depends="coverage, findbugs, dist">
</target>
<target name="svn.info">
<svn>
<status path="${basedir}" revisionProperty="svn.revision" urlProperty="svn.url"/>
</svn>
<!-- If we can't find the revision for some reason, set it to 'unknown revision' -->
<property name="svn.revision" value="unknown-revision"/>
<property name="svn.url" value="unknown-url"/>
<echo message="Subversion Revision: ${svn.revision}"/>
</target>
<target name="git.info">
<exec executable="git" outputproperty="git.tagstring">
<arg value="describe"/>
</exec>
<exec executable="git" outputproperty="git.revision">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="git.url">
<arg line="ls-remote --get-url"/>
</exec>
<echo message="Git Revision: ${git.revision}"/>
<echo message="Git Repo: ${git.url}"/>
</target>
<target name="diagnostics" description="diagnostics">
<diagnostics/>
</target>
<target name="junit-tests" >
<mkdir dir="${reports.tests}"/>
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<pathelement location="${project.class.path}"/>
<pathelement location="${build.tests}"/>
<pathelement path="${java.class.path}"/>
</classpath>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${reports.tests}">
<fileset dir="${src.test}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
</project>