-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
319 lines (285 loc) · 12.9 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
<project name="Genyris" default="build-workspace" basedir=".">
<property environment="env"/>
<property name="build.compiler" value="javac1.6" />
<property name="needed.lib.dir" value="needed" />
<property name="junit.lib.dir" value="needed" />
<property name="build.dir" value="build" />
<property name="dist.dir" value="dist" />
<property name="rel.dir" value="rel" />
<property name="src.compile.dir" value="${build.dir}/classes" />
<property name="src.dir" value="src" />
<property name="version.dir" value="${src.dir}/org/genyris/load/boot" />
<property file="secrets.properties" />
<property name="git.describe.file" value="${build.dir}/git-describe.txt" />
<taskdef resource="checkstyletask.properties" classpath="${needed.lib.dir}/checkstyle-5.3-all.jar" />
<tstamp>
<format property="TODAY" pattern="dd/MM/yyyy HH:mm:ss" />
</tstamp>
<target name="clean" depends="only-clean" />
<target name="compile" depends="only-clean, only-init, only-compile" description="Compile the Java" />
<target name="binary" depends="version-default,compile, only-make-jar, only-compile-docs, only-binary" description="create jar, zips, documentation, installers" />
<target name="make-jar" depends="version-default,compile, only-make-jar" description="compile and create jar" />
<target name="build-workspace" depends="only-clean, only-init, version-default, binary, package, test, reports" description="Build and test current workspace contents." />
<target name="release" depends="tagged-version, binary, package, test, reports" description="Build a formal tagged release using only the latest tag." />
<!-- Libraries required -->
<fileset id="needed.libs" dir="${needed.lib.dir}">
<include name="bsf.jar" />
<include name="commons-logging-1.1.jar" />
<include name="servlet-api.jar" />
<include name="junit.jar" />
<include name="dsn.jar" />
<include name="imap.jar" />
<include name="mail.jar" />
<include name="mailapi.jar" />
<include name="pop3.jar" />
<include name="smtp.jar" />
<include name="opencsv-1.8.jar" />
<include name="jline-2.11.jar" />
<include name="commons-io-2.4.jar" />
<include name="httpcore-4.4.3.jar" />
<include name="httpclient-4.5.1.jar" />
<include name="org.json.jar" />
</fileset>
<!-- Properties files from the classpath -->
<fileset id="product.properties.files" dir="${java.src.dir}">
<include name="*.properties" />
</fileset>
<!-- Classpath for JUnit testing -->
<fileset id="junit.libs" file="${junit.lib.dir}/junit.jar" />
<!-- ================================================================== -->
<!-- Classpaths -->
<!-- ================================================================== -->
<path id="src.compile.classpath">
<fileset refid="needed.libs" />
<fileset refid="junit.libs" />
</path>
<!-- ================================================================== -->
<!-- Targets -->
<!-- ================================================================== -->
<target name="debug">
<echoproperties />
</target>
<target name="version-default" depends="git-info" description="Compute version number from Git.">
<property name="implementation-version" value="${git.workspace.version}-${build.id}" />
<property name="version" value="${implementation-version}" />
<loadresource property="version.underscores">
<propertyresource name="implementation-version" />
<filterchain>
<tokenfilter>
<filetokenizer />
<replacestring from="." to="_" />
</tokenfilter>
</filterchain>
</loadresource>
<echo>Version = ${version}</echo>
<echo>Version.underscores = '${version.underscores}'</echo>
<echo>implementation-version = '${implementation-version}'</echo>
</target>
<target name="git-info" description="Extract Git information." depends="only-git-workspace, only-git-status">
<property name="specification-version" value="${git.workspace.specification.version}" />
<buildnumber file="${git.workspace.version}-build.number" />
<property name="build.id" value="${build.number}" />
<echo>specification version = ${specification-version}</echo>
<echo>Build Number = ${build.id}</echo>
<echo>version = ${version}</echo>
</target>
<target name="git-committed" description="Fail if uncommitted changes" depends="only-git-status">
<fail if="working-folder-has-uncommited-changes" />
</target>
<target name="only-git-status" description="look for uncommitted files">
<exec executable="bash" outputproperty="git.status" errorproperty="git.error" failonerror="true">
<arg value="-c" />
<arg value="git status --porcelain | wc -l" />
</exec>
<condition property="working-folder-has-uncommited-changes">
<not>
<equals arg1="${git.status}" arg2="0" />
</not>
</condition>
<echo>git.status = ${git.status}</echo>
<echo>working-folder-has-uncommited-changes = ${working-folder-has-uncommited-changes}</echo>
</target>
<target name="only-git-workspace">
<exec executable="git" outputproperty="git.workspace.version" errorproperty="git.error" failonerror="true">
<arg value="describe" />
<arg value="--tags" />
</exec>
<echo>git.workspace.version = ${git.workspace.version}</echo>
<exec executable="git" output="${git.describe.file}" errorproperty="git.error" failonerror="true">
<arg value="describe" />
<arg value="--tags" />
<arg value="--abbrev=0" />
</exec>
<loadfile srcfile="${git.describe.file}" property="git.workspace.tag" />
<echo>git.workspace.tag = ${git.workspace.tag}</echo>
<condition property="workspace-contains-a-tagged-version">
<equals arg1="${git.workspace.tag}" arg2="${git.workspace.version}" />
</condition>
<echo>workspace-contains-a-tagged-version = ${workspace-contains-a-tagged-version}</echo>
<loadfile srcfile="${git.describe.file}" property="git.workspace.specification.version">
<filterchain>
<headfilter lines="1" skip="0" />
<tokenfilter>
<replaceregex pattern="\.[0-9]+$" replace="" flags="gi" />
</tokenfilter>
<striplinebreaks />
</filterchain>
</loadfile>
<echo>git.workspace.specification.version = ${git.workspace.specification.version}</echo>
</target>
<target name="tagged-version" depends="git-info, git-committed">
<fail unless="workspace-contains-a-tagged-version" />
</target>
<target name="only-init">
<mkdir dir="${build.dir}" />
<mkdir dir="${version.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${rel.dir}" />
<mkdir dir="${src.compile.dir}" />
</target>
<target name="only-clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${rel.dir}" />
</target>
<target name="only-compile">
<javac srcdir="${src.dir}" destdir="${src.compile.dir}" classpathref="src.compile.classpath" source="1.8" target="1.8" verbose="no" includeantruntime="false">
<include name="org/**" />
<include name="com/**" />
</javac>
</target>
<target name="only-compile-docs" description="Create PDF manual" depends="git-info">
<copy file="doc/reference/manual.lyx" tofile="dist/genyris-manual-${version}.lyx" verbose="true" overwrite="true">
<filterchain>
<replacetokens>
<token key="GENYRIS-SPECIFICATION-VERSION" value="${specification-version}" />
<token key="GENYRIS-IMPLEMENTATION-VERSION" value="${implementation-version}" />
</replacetokens>
</filterchain>
</copy>
<copy todir="dist" verbose="true">
<fileset dir="${basedir}/doc/reference/">
<include name="*jpg" />
</fileset>
</copy>
<exec executable="lyx" dir="dist" failonerror="true" output="dist/lyx.log" >
<arg value="-batch" />
<arg value="--export" />
<arg value="pdf" />
<arg value="genyris-manual-${version}.lyx" />
</exec>
<exec executable="/usr/bin/elyxer" dir="dist" failonerror="true" output="dist/elyxer.log">
<arg value="genyris-manual-${version}.lyx" />
<arg value="genyris-manual-${version}.html" />
</exec>
<delete verbose="true">
<fileset dir="dist">
<include name="*jpg" />
<include name="*lyx" />
<include name="*dvi" />
</fileset>
</delete>
<copy file="dist/genyris-manual-${version}.pdf" tofile="rel/genyris-manual-${version}.pdf" verbose="true" />
<checksum file="rel/genyris-manual-${version}.pdf" forceOverwrite="yes" />
<copy file="dist/genyris-manual-${version}.html" tofile="rel/genyris-manual-${version}.html" verbose="true" />
<checksum file="rel/genyris-manual-${version}.html" forceOverwrite="yes" />
</target>
<target name="only-binary" depends="make-jar, only-compile-docs" description="Make a binary release">
<tstamp />
<copy todir="dist" verbose="false">
<fileset dir="${basedir}">
<include name="needed/**/*jar" />
</fileset>
</copy>
<zip destfile="rel/genyris-binary-${version}.zip" duplicate="fail" defaultexcludes="no">
<fileset dir="${basedir}">
<include name="LICENSE" />
<include name="README" />
<include name="dist/**/*" />
<include name="lib/**/*" />
<include name="bin/**/*" />
<include name="examples/**/*" />
<include name="test/**/*" />
</fileset>
</zip>
<checksum file="rel/genyris-binary-${version}.zip" forceOverwrite="yes" />
</target>
<target name="archive" depends="make-jar" description="Make a backup">
<input message="Destination directory for archive?" addproperty="archive.dest" />
<tstamp />
<jar destfile="${archive.dest}/genyris-archive-${DSTAMP}${TSTAMP}.jar" duplicate="fail" defaultexcludes="no">
<fileset dir="${basedir}" includes="*" />
<fileset dir="${basedir}" includes="*/**/*">
<exclude name="idebuild/**/*" />
<exclude name="build/**/*" />
</fileset>
</jar>
</target>
<target name="only-make-jar">
<jar destfile="${dist.dir}/genyris-bin-${version}.jar" duplicate="fail">
<fileset dir="${basedir}" includes="README LICENSE" />
<fileset dir="${build.dir}" includes="version/**/*" />
<fileset dir="${src.compile.dir}" includes="**/*.class" excludes="**/GenyrisServlet.class" />
<fileset dir="${needed.lib.dir}" includes="junit/**/*" />
<fileset dir="${src.dir}" includes="**/*.g" />
<fileset dir="${src.dir}" includes="**/*.properties" />
<fileset dir="${basedir}" includes="test/**/*" />
<manifest>
<attribute name="Main-Class" value="org.genyris.interp.ClassicReadEvalPrintLoop" />
<attribute name="Specification-Title" value="Genyris" />
<attribute name="Specification-Version" value="${specification-version}" />
<attribute name="Specification-Vendor" value="genyris.org" />
<attribute name="Implementation-Title" value="Genyris" />
<attribute name="Implementation-Version" value="${implementation-version}" />
<attribute name="Implementation-Vendor" value="Peter William Birch" />
<attribute name="Implementation-Date" value="${TODAY}" />
</manifest>
</jar>
</target>
<target name="test" depends="binary, only-test" />
<target name="only-test" depends="git-info">
<exec executable="bash" failonerror="true">
<env key="GENYRIS_HOME" value="${basedir}" />
<arg value="-c" />
<arg value="-u" />
<arg value="-x" />
<arg value="xvfb-run java -Xmx256M -classpath ${GENYRIS_HOME}/dist/\*:${GENYRIS_HOME}/dist/needed/\* org.genyris.interp.ClassicReadEvalPrintLoop test/acceptance/suite.g" />
</exec>
</target>
<target name="reports" depends="only-report-todo" />
<target name="only-report-todo">
<exec executable="bash" failonerror="true">
<env key="GENYRIS_HOME" value="${basedir}" />
<arg value="-c" />
<arg value="java -Xmx256M -classpath ${GENYRIS_HOME}/dist/\*:${GENYRIS_HOME}/dist/needed/\* org.genyris.interp.ClassicReadEvalPrintLoop examples/file-lines.g '.*\.g$|.*\.java$|.*\.lyx' '.*TODO.*|.*FIXME.*' ${basedir}"/>
</exec>
</target>
<target name="checkstyle" description="Check Java code Style.">
<mkdir dir="reports" />
<checkstyle config="conf/BillBirchCheck.xml">
<fileset dir="${src.dir}" includes="**/*.java" />
<formatter type="plain" />
<formatter type="xml" toFile="dist/checkstyle_errors.xml" />
</checkstyle>
</target>
<target name="package" depends="version-default" description="Install4j Packaging, generates exe, deb and dmg">
<copy file="package/genyris.install4j" tofile="dist/genyris.install4j" verbose="true" overwrite="true">
<filterchain>
<replacetokens>
<token key="GENYRIS-VERSION" value="${version}" />
</replacetokens>
</filterchain>
</copy>
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="-x" />
<arg value="-u" />
<arg value="install4jc --disable-bundling --license="$INSTALL4J_LICENSE" dist/genyris.install4j" />
</exec>
<checksum file="rel/genyris_windows-x64_${version.underscores}.zip" forceOverwrite="yes" />
<checksum file="rel/genyris_unix_${version.underscores}.tar.gz" forceOverwrite="yes" />
<checksum file="rel/genyris_linux_${version.underscores}.deb" forceOverwrite="yes" />
<checksum file="rel/genyris_linux_${version.underscores}.rpm" forceOverwrite="yes" />
<checksum file="rel/genyris_macos_${version.underscores}.dmg" forceOverwrite="yes" />
</target>
</project>