forked from LinkedInAttic/datafu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
296 lines (261 loc) · 11.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
<project name="datafu" basedir="." default="all"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="build.properties" />
<property name="name" value="datafu" />
<property name="display.name" value="DataFu" />
<property name="author" value="Matthew Hayes, Sam Shah" />
<property environment="env" />
<property name="ivy.jar.dir" value="${basedir}/ivy" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-2.2.0.jar" />
<target name="all" depends="clean, jar, srcjar, docs, coverage" description="Build all artifacts." />
<!-- TODO need a release target -->
<target name="install-ivy" description="install ivy">
<path id="ivy.lib.path">
<pathelement location="${ivy.jar.file}"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="ivy-resolve" depends="install-ivy" description="retreive dependencies with ivy">
<ivy:retrieve/>
</target>
<target name="check-licenses" description="checks that source files have license header">
<exec executable="./check-license-headers.sh" failonerror="true"/>
</target>
<target name="clean-cache" depends="install-ivy" description="clean the ivy cache">
<ivy:cleancache />
</target>
<path id="main-classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<pathelement path="${classes.dir}" />
</path>
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<path id="base-test-classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${basedir}/otherlibs">
<include name="*.jar" />
</fileset>
<pathelement path="${pigtestclasses.dir}" />
<pathelement path="${unittestclasses.dir}" />
</path>
<path id="test-classpath">
<path refid="base-test-classpath" />
<!-- Use non-instrumented JARs for normal testing, otherwise it is 15% slower to run the tests -->
<fileset dir="${dist.dir}">
<include name="*.jar" />
</fileset>
</path>
<path id="instrumented-test-classpath">
<path refid="base-test-classpath" />
<path refid="cobertura.classpath" />
<!-- Use instrumented JARs -->
<fileset dir="${instrumented.dir}">
<include name="*.jar" />
</fileset>
</path>
<macrodef name="replace-dir">
<attribute name="dir" />
<sequential>
<delete dir="@{dir}" />
<mkdir dir="@{dir}" />
</sequential>
</macrodef>
<target name="clean" description="Delete generated files.">
<delete dir="${lib.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${docs.dir}" />
<delete dir="${report.dir}" />
<delete dir="${coveragereport.dir}"/>
<delete dir="${instrumented.dir}"/>
<delete dir="test-output"/>
<delete file="cobertura.ser"/>
</target>
<target name="build" depends="ivy-resolve" description="Compile main source tree java files">
<replace-dir dir="${classes.dir}" />
<javac destdir="${classes.dir}" target="1.5" debug="true" deprecation="false" failonerror="true" includeantruntime="false">
<src path="${java.dir}" />
<exclude name="datafu/linkedin/**"/>
<classpath refid="main-classpath" />
</javac>
</target>
<target name="build-unit-tests" depends="build" description="Compile unit test classes">
<replace-dir dir="${unittestclasses.dir}" />
<javac destdir="${unittestclasses.dir}" target="1.5" debug="true" deprecation="false" failonerror="true" includeantruntime="false">
<src path="${unittestsrc.dir}" />
<classpath refid="main-classpath" />
</javac>
</target>
<target name="build-pig-tests" depends="build, build-unit-tests" description="Compile pig test classes">
<replace-dir dir="${pigtestclasses.dir}" />
<copy todir="${pigtestclasses.dir}">
<fileset dir="${pigtestsrc.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
<javac destdir="${pigtestclasses.dir}" target="1.5" debug="true" deprecation="false" failonerror="true" includeantruntime="false">
<src path="${pigtestsrc.dir}" />
<classpath refid="test-classpath" />
</javac>
</target>
<target name="jar-core" depends="build" description="Build the JAR file with the core code from the library">
<delete file="${dist.dir}/${name}-${curr.release}.jar" />
<jar destfile="${dist.dir}/${name}-${curr.release}.jar">
<fileset dir="${classes.dir}">
<include name="**/*.*" />
</fileset>
</jar>
</target>
<target name="jar-fastutil" depends="jar-core" description="Builds the JAR with fastutil included">
<delete file="${dist.dir}/${name}-${curr.release}-orig.jar" />
<move file="${dist.dir}/${name}-${curr.release}.jar" tofile="${dist.dir}/${name}-${curr.release}-orig.jar" />
<java jar="${tools.dir}/autojar.jar" fork="true">
<arg line="-baeq -o ${dist.dir}/${name}-${curr.release}.jar -c ${lib.dir}/fastutil-6.3.jar ${dist.dir}/${name}-${curr.release}-orig.jar" />
</java>
<delete file="${dist.dir}/${name}-${curr.release}-orig.jar" />
</target>
<target name="jar" depends="jar-fastutil" description="Builds the final JAR">
<delete file="${dist.dir}/${name}-${curr.release}-orig.jar" />
<move file="${dist.dir}/${name}-${curr.release}.jar" tofile="${dist.dir}/${name}-${curr.release}-orig.jar" />
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="tools/jarjar-1.1.jar"/>
<jarjar jarfile="${dist.dir}/${name}-${curr.release}.jar">
<zipfileset src="${dist.dir}/${name}-${curr.release}-orig.jar"/>
<rule pattern="it.unimi.dsi.fastutil.**" result="datafu.it.unimi.dsi.fastutil.@1"/>
</jarjar>
<delete file="${dist.dir}/${name}-${curr.release}-orig.jar" />
</target>
<target name="jar-instrumented" depends="jar" description="Build an instrumented jar">
<delete file="cobertura.ser" />
<replace-dir dir="${instrumented.dir}" />
<cobertura-instrument todir="${instrumented.dir}">
<includeClasses regex=".*datafu.*" />
<excludeClasses regex=".*fastutil.*" />
<excludeClasses regex=".*test.*" />
<!-- Code coverage on LinkedIn specific code is not a priority right now -->
<excludeClasses regex=".*linkedin.*"/>
<instrumentationClasspath>
<pathelement location="${dist.dir}"/>
</instrumentationClasspath>
</cobertura-instrument>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="tools/jarjar-1.1.jar"/>
<delete file="${instrumented.dir}/${name}-${curr.release}.jar" />
<!-- Classes are now instrumented, but we need to merge back with original JAR to get back what was lost, since
we don't instrument everything and therefore classes are missing form the instrumented directory. -->
<jarjar jarfile="${instrumented.dir}/${name}-${curr.release}.jar">
<zipfileset src="${dist.dir}/${name}-${curr.release}.jar"/>
<!-- Classes in instrumented directory come last so they take precedence over the classes in the JAR.
We need to include the JAR so we get the fastutil classes. The fastutil classes are not instrumented (by design),
so they are not in the instrumented directory. -->
<fileset dir="${instrumented.dir}" />
</jarjar>
</target>
<target name="test" depends="build-pig-tests, build-unit-tests, jar" description="Runs the pig tests">
<taskdef resource="testngtasks" classpath="lib/testng-6.2.jar"/>
<testng classpathref="test-classpath"
outputDir="${report.dir}" verbose="2">
<jvmarg value="-Xmx1G" />
<sysproperty key="datafu.jar.dir" value="${dist.dir}" />
<classfileset dir="${unittestclasses.dir}" includes="${testclasses.pattern}" />
<classfileset dir="${pigtestclasses.dir}" includes="${testclasses.pattern}" />
</testng>
</target>
<target name="test-instrumented" depends="build-pig-tests, build-unit-tests, jar-instrumented" description="Runs the tests with instrumented JARs">
<taskdef resource="testngtasks" classpath="lib/testng-6.2.jar"/>
<testng classpathref="instrumented-test-classpath"
outputDir="${report.dir}" >
<jvmarg value="-Xmx1G" />
<sysproperty key="datafu.jar.dir" value="${instrumented.dir}" />
<classfileset dir="${pigtestclasses.dir}" includes="${testclasses.pattern}" />
<classfileset dir="${unittestclasses.dir}" includes="${testclasses.pattern}" />
</testng>
</target>
<target name="coverage" depends="test-instrumented" description="Generates the code coverage report">
<replace-dir dir="${coveragereport.dir}" />
<cobertura-report format="html" destdir="${coveragereport.dir}">
<fileset dir="${java.dir}">
<include name="**/*.java" />
</fileset>
</cobertura-report>
<!-- Build a WAR containing the coverage report which can be deployed to tomcat -->
<mkdir dir="${dist.dir}" />
<war destfile="${dist.dir}/${name}-coverage.war" needxmlfile="false">
<fileset dir="${coveragereport.dir}" />
</war>
</target>
<target name="srcjar" description="Build source jar file">
<mkdir dir="${dist.dir}" />
<jar destfile="${dist.dir}/${name}-${curr.release}-sources.jar">
<fileset dir="${java.dir}">
<include name="**/*.java" />
</fileset>
</jar>
</target>
<macrodef name="make-javadocs">
<attribute name="dir" />
<attribute name="packagenames" />
<attribute name="javadir" />
<sequential>
<replace-dir dir="@{dir}" />
<javadoc sourcepath="@{javadir}" destdir="@{dir}" windowtitle="${display.name}" source="1.5" author="true" version="true" use="true" packagenames="@{packagenames}">
<doctitle>${display.name}</doctitle>
<bottom>${author}</bottom>
<classpath refid="main-classpath" />
</javadoc>
</sequential>
</macrodef>
<target name="docs" description="Create complete Javadoc documentation">
<delete dir="${javadoc.dir}" />
<make-javadocs dir="${javadoc.dir}" packagenames="*" javadir="${java.dir}"/>
<!-- Make javadoc JAR -->
<mkdir dir="${dist.dir}" />
<jar destfile="${dist.dir}/${name}-${curr.release}-javadoc.jar">
<fileset dir="${javadoc.dir}">
<include name="**/*.*" />
</fileset>
</jar>
<!-- Make a WAR for the docs so can be deployed to tomcat -->
<mkdir dir="${dist.dir}" />
<war destfile="${dist.dir}/${name}-docs.war" needxmlfile="false">
<fileset dir="${javadoc.dir}" />
</war>
</target>
<macrodef name="create-release-artifacts">
<attribute name="version" />
<sequential>
<antcall target="all"/>
<zip destfile="${dist.dir}/${name}-@{version}.zip">
<zipfileset dir="." prefix="${name}-@{version}" includes="**">
<exclude name="${dist.dir}/classes/**"/>
<exclude name="${dist.dir}/pigtestclasses/**"/>
<exclude name="${dist.dir}/unittestclasses/**"/>
<exclude name=".git*/**"/>
<exclude name="input"/>
<exclude name="pigunit-input-overriden.txt"/>
</zipfileset>
</zip>
<tar destfile="${dist.dir}/${name}-@{version}.tar.gz" compression="gzip" longfile="gnu">
<tarfileset dir="." prefix="${name}-@{version}" includes="**">
<exclude name="${dist.dir}/classes/**"/>
<exclude name="${dist.dir}/pigtestclasses/**"/>
<exclude name="${dist.dir}/unittestclasses/**"/>
<exclude name="${dist.dir}/*.zip"/>
<exclude name=".git*/**"/>
<exclude name="input"/>
<exclude name="pigunit-input-overriden.txt"/>
</tarfileset>
</tar>
</sequential>
</macrodef>
<target name="release" description="Create a release zip file with everything pre-built.">
<create-release-artifacts version="${curr.release}" />
</target>
</project>