forked from linkedin/parseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
345 lines (295 loc) · 15.4 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
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="parseq" default="build" basedir=".">
<description>ParSeq Project</description>
<property name="src.dir" value="${basedir}/src" />
<property name="src.fmpp.dir" location="${basedir}/fmpp/templates" />
<property name="src.fmpp.data" location="${basedir}/fmpp/data" />
<property name="test.dir" value="${basedir}/test" />
<property name="src.test.dir" value="${basedir}/src-test" />
<property name="tools.dir" value="${basedir}/tools" />
<property name="contrib.dir" value="${basedir}/contrib" />
<property name="build.dir" value="${basedir}/build" />
<property name="src.build.dir" value="${build.dir}/src" />
<property name="lib.build.dir" value="${build.dir}/lib" />
<property name="test.build.dir" value="${build.dir}/test" />
<property name="src.test.build.dir" value="${build.dir}/src-test" />
<property name="test.result.dir" value="${test.build.dir}/reports"/>
<property name="doc.build.dir" value="${build.dir}/doc"/>
<property name="doc.test.build.dir" value="${build.dir}/doc-test"/>
<property name="dist.dir" value="${basedir}/dist" />
<property name="dot.location" value="/usr/local/bin/dot" />
<property name="dist.test.dir" value="${basedir}/dist-test" />
<!-- IVY configuration -->
<property name="ivy.jar.version" value="2.2.0" />
<property name="ivy.jar.file" value="${build.dir}/ivy.jar" />
<property name="ivy.jar.url" value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.jar.version}/ivy-${ivy.jar.version}.jar" />
<!-- This has special meaning for the ivy:retrieve task: it points to the location the JARs will be placed -->
<property name="ivy.lib.dir" value="${lib.build.dir}"/>
<property name="javac.source" value="1.8" />
<property name="javac.target" value="1.8" />
<!-- Enables/disables inclusion of debug symbols in .class files. -->
<property name="debug" value="true" />
<!-- How verbose should testng be? A value of 2 or greater logs tests that
are run and test failure stack traces to the console -->
<property name="testng.verbosity" value="1"/>
<path id="build.classpath">
<pathelement location="${src.build.dir}"/>
<fileset dir="${lib.build.dir}/build" includes="*.jar"/>
</path>
<path id="test.classpath">
<path refid="build.classpath"/>
<pathelement location="${src.test.build.dir}"/>
<pathelement location="${test.build.dir}"/>
<fileset dir="${lib.build.dir}/test" includes="*.jar"/>
</path>
<condition property="dot.found">
<available file="${dot.location}"/>
</condition>
<target name="bootstrap" unless="bootstrap.done">
<mkdir dir="${lib.build.dir}"/>
<!-- Pull down IVY and load taskdefs -->
<get src="${ivy.jar.url}" dest="${ivy.jar.file}" usetimestamp="true" />
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant">
<classpath>
<fileset file="${ivy.jar.file}" />
</classpath>
</taskdef>
<ivy:resolve file="ivy.xml" conf="bootstrap"/>
<ivy:retrieve pattern="${ivy.lib.dir}/[conf]/[artifact].[ext]"/>
<!-- load testng taskdefs -->
<taskdef resource="testngtasks">
<classpath>
<fileset file="${lib.build.dir}/bootstrap/testng.jar"/>
</classpath>
</taskdef>
<!-- load fmpp taskdefs -->
<taskdef name="fmpp" classname="fmpp.tools.AntTask">
<classpath>
<fileset dir="${lib.build.dir}/bootstrap" includes="*.jar"/>
</classpath>
</taskdef>
<property name="bootstrap.done" value="true"/>
</target>
<target name="version-props" unless="version">
<loadproperties srcFile="${basedir}/version.properties"/>
</target>
<target name="prepare" depends="bootstrap, version-props">
<mkdir dir="${src.build.dir}" />
<mkdir dir="${lib.build.dir}" />
<mkdir dir="${test.build.dir}" />
<mkdir dir="${src.test.build.dir}" />
<mkdir dir="${test.result.dir}"/>
<mkdir dir="${doc.build.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.test.dir}" />
<ivy:resolve file="ivy.xml" conf="*"/>
<ivy:retrieve pattern="${ivy.lib.dir}/[conf]/[artifact].[ext]"/>
</target>
<target name="generate-src" depends="prepare"
description="Builds java source files from templates.">
<fmpp excludes="**/macros.ftl"
sourceRoot="${src.fmpp.dir}"
outputRoot="${src.dir}"
data="tdd(../data/fmpp.tdd)"/>
</target>
<target name="build-src" depends="prepare, generate-src" description="Builds src.">
<javac includeantruntime="false" destdir="${src.build.dir}" source="${javac.source}" target="${javac.target}" debug="${debug}">
<src path="${src.dir}"/>
<classpath refid="build.classpath"/>
<compilerarg value="-Xlint"/>
</javac>
</target>
<target name="build-src-test" depends="build-src" description="Builds src-test files.">
<javac includeantruntime="false" destdir="${src.test.build.dir}" source="${javac.source}" target="${javac.target}" debug="${debug}">
<src path="${src.test.dir}"/>
<classpath refid="test.classpath"/>
<compilerarg value="-Xlint"/>
</javac>
</target>
<target name="jar-src" depends="build-src" description="Creates a JAR for src classes">
<make-jar destfile="${dist.dir}/${ant.project.name}-${version}.jar" basedir="${src.build.dir}" />
</target>
<target name="jar-src-test" depends="build-src-test" description="Creates a JAR for src-test classes">
<make-jar destfile="${dist.dir}/${ant.project.name}-${version}-test.jar" basedir="${src.test.build.dir}" />
</target>
<target name="zip-src" depends="prepare" description="Creates a ZIP for the src files">
<make-jar destfile="${dist.dir}/${ant.project.name}-${version}-sources.jar" basedir="${src.dir}" />
</target>
<target name="zip-src-test" depends="prepare" description="Creates a ZIP for the src-test files">
<make-jar destfile="${dist.dir}/${ant.project.name}-${version}-test-sources.jar" basedir="${src.test.dir}" />
</target>
<target name="tar-tracevis" depends="prepare, dist-tracevis" description="Creates a tarball of the tracevis tool">
<copy file="${tools.dir}/tracevis/dist/parseq-tracevis.tar.gz" tofile="${dist.dir}/parseq-tracevis-${version}.tar.gz"/>
</target>
<target name="doc" description="Build the javadoc." depends="build-src">
<javadoc destdir="${doc.build.dir}" additionalparam="-Xdoclint:none">
<packageset dir="${src.dir}">
<exclude name="com/linkedin/parseq/internal"/>
</packageset>
<classpath refid="build.classpath"/>
</javadoc>
</target>
<target name="doc-test" description="Build the javadoc for test artifact." depends="build-src-test">
<javadoc destdir="${doc.test.build.dir}" additionalparam="-Xdoclint:none">
<packageset dir="${src.test.dir}"/>
<classpath refid="test.classpath"/>
</javadoc>
</target>
<target name="zip-doc" depends="doc" description="Creates a ZIP for the javadoc files">
<make-jar destfile="${dist.dir}/${ant.project.name}-${version}-javadoc.jar" basedir="${doc.build.dir}" />
</target>
<target name="zip-doc-test" depends="doc-test" description="Creates a ZIP for the javadoc files of test artifact">
<make-jar destfile="${dist.dir}/${ant.project.name}-${version}-test-javadoc.jar" basedir="${doc.test.build.dir}" />
</target>
<target name="build-test" depends="build-src, build-src-test" description="Builds test files.">
<javac includeantruntime="false" destdir="${test.build.dir}" source="${javac.source}" target="${javac.target}" debug="${debug}">
<src path="${test.dir}"/>
<classpath refid="test.classpath"/>
<compilerarg value="-Xlint"/>
</javac>
<copy file="${test.dir}/log4j.properties" todir="${test.build.dir}"/>
</target>
<target name="test" depends="test-unit, test-tracevis"
description="Runs the unit and integration tests. Set property no.test.tracevis to skip visualization tests."/>
<target name="test-unit" depends="build-test" description="Runs the unit tests.">
<testng haltonfailure="true" outputDir="${test.result.dir}" verbose="${testng.verbosity}">
<classfileset dir="${test.build.dir}" includes="**/Test*.class"/>
<classpath refid="test.classpath"/>
</testng>
</target>
<target name="build" depends="build-src,build-test" description="Builds everything" />
<target name="dist" depends="jar-src, zip-src, tar-tracevis, zip-doc, jar-src-test, zip-src-test, zip-doc-test"
description="Builds all distributables to ${dist.dir}">
<ivy:deliver deliverpattern="${dist.dir}/[artifact]-[revision].[ext]" pubrevision="${version}" validate="true"/>
<ivy:resolve file="tracevis-ivy.xml" conf="default"/>
<ivy:deliver deliverpattern="${dist.dir}/tracevis-[artifact]-[revision].[ext]" pubrevision="${version}" validate="true"/>
<property name="ivy.pom.description" value="ParSeq is a framework that makes it easier to write and maintain fast, scalable applications in Java"/>
<property name="ivy.pom.url" value="https://github.com/linkedin/parseq"/>
<ivy:makepom ivyfile="${dist.dir}/ivy-${version}.xml" pomfile="${dist.dir}/parseq-${version}.pom" templatefile="${basedir}/build-templates/template.pom" conf="build">
<mapping conf="build" scope="compile"/>
</ivy:makepom>
<ivy:makepom ivyfile="${dist.dir}/tracevis-ivy-${version}.xml" pomfile="${dist.dir}/parseq-tracevis-${version}.pom" templatefile="${basedir}/build-templates/template.pom" conf="build">
</ivy:makepom>
</target>
<target name="bundle-parseq" depends="dist"
description="Builds a release bundle to ${dist.dir}/parseq-${version}-bundle.jar">
<sign file="${dist.dir}/parseq-${version}.pom"/>
<sign file="${dist.dir}/parseq-${version}.jar"/>
<sign file="${dist.dir}/parseq-${version}-sources.jar"/>
<sign file="${dist.dir}/parseq-${version}-javadoc.jar"/>
<sign file="${dist.dir}/parseq-${version}-test.jar"/>
<sign file="${dist.dir}/parseq-${version}-test-sources.jar"/>
<sign file="${dist.dir}/parseq-${version}-test-javadoc.jar"/>
<jar destfile="${dist.dir}/parseq-${version}-bundle.jar" basedir="${dist.dir}">
<include name="parseq-${version}.pom"/>
<include name="parseq-${version}.pom.asc"/>
<include name="parseq-${version}.jar"/>
<include name="parseq-${version}.jar.asc"/>
<include name="parseq-${version}-sources.jar"/>
<include name="parseq-${version}-sources.jar.asc"/>
<include name="parseq-${version}-javadoc.jar"/>
<include name="parseq-${version}-javadoc.jar.asc"/>
<include name="parseq-${version}-test.jar"/>
<include name="parseq-${version}-test.jar.asc"/>
<include name="parseq-${version}-test-sources.jar"/>
<include name="parseq-${version}-test-sources.jar.asc"/>
<include name="parseq-${version}-test-javadoc.jar"/>
<include name="parseq-${version}-test-javadoc.jar.asc"/>
</jar>
</target>
<target name="bundle-tracevis" depends="dist"
description="Builds a release bundle to ${dist.dir}/parseq-tracevis-${version}-bundle.jar">
<sign file="${dist.dir}/parseq-tracevis-${version}.pom"/>
<sign file="${dist.dir}/parseq-tracevis-${version}.tar.gz"/>
<jar destfile="${dist.dir}/parseq-tracevis-${version}-bundle.jar" basedir="${dist.dir}">
<include name="parseq-tracevis-${version}.pom"/>
<include name="parseq-tracevis-${version}.pom.asc"/>
<include name="parseq-tracevis-${version}.tar.gz"/>
<include name="parseq-tracevis-${version}.tar.gz.asc"/>
</jar>
</target>
<target name="bundle" depends="bundle-parseq, bundle-tracevis"
description="Builds all release bundsles to ${dist.dir}"/>
<target name="clean" description="Cleans build and dist dirs">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<make dir="${tools.dir}/tracevis" >
<args>
<arg value="clean" />
</args>
</make>
<exec executable="mvn" failonerror="true" dir="${contrib.dir}/parseq-tracevis-server">
<arg value="clean"/>
</exec>
</target>
<target name="test-tracevis" unless="no.test.tracevis" description="Run visualization tests">
<make dir="${tools.dir}/tracevis">
<args>
<arg value="test" />
</args>
</make>
</target>
<target name="dist-tracevis" description="Builds the tracevis package">
<make dir="${tools.dir}/tracevis">
<args>
<arg value="dist" />
</args>
</make>
</target>
<target name="package-tracevis-server" description="Builds the tracevis-server package">
<exec executable="mvn" failonerror="true" dir="${contrib.dir}/parseq-tracevis-server">
<arg value="package"/>
</exec>
</target>
<target name="verify-dot-exists">
<fail message="Did not find dot under ${dot.location}. Make sure graphviz is installed and property dot.location points to dot executable." unless="${dot.found}"/>
</target>
<target name="run-tracevis-server" depends="verify-dot-exists, dist-tracevis, package-tracevis-server" description="Runs the tracevis-server" >
<java fork="true" jar="${contrib.dir}/parseq-tracevis-server/target/parseq-tracevis-server-jar-with-dependencies.jar" failonerror="true">
<arg value="${dot.location}" />
</java>
</target>
<macrodef name="sign">
<attribute name="file"/>
<sequential>
<echo message="Signing @{file}"/>
<!-- Note: we currently use the default key for signing. We can add
support for alternate keys using the -u option. -->
<exec executable="gpg" failonerror="true">
<arg value="-a"/>
<arg value="-b"/>
<arg value="@{file}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="make-jar">
<attribute name="destfile"/>
<attribute name="basedir"/>
<sequential>
<git-sha1 outputproperty="sha1"/>
<jar destfile="@{destfile}" basedir="@{basedir}">
<manifest>
<attribute name="Implementation-Version" value="${sha1}"/>
</manifest>
</jar>
</sequential>
</macrodef>
<macrodef name="make">
<attribute name="dir" />
<element name="args" />
<sequential>
<exec executable="make" failonerror="true" dir="@{dir}">
<args/>
</exec>
</sequential>
</macrodef>
<macrodef name="git-sha1">
<attribute name="outputproperty"/>
<sequential>
<exec executable="git" dir="${basedir}" outputproperty="@{outputproperty}">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
</sequential>
</macrodef>
</project>