forked from splunk/splunk-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
451 lines (393 loc) · 17.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
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2011 Splunk, Inc.
Licensed under the Apache License, Version 2.0 (the "License"): you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<project name="splunk-sdk-java" basedir="." default="dist" xmlns:jacoco="antlib:org.jacoco.ant"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="antlib:org.jacoco.ant ">
<property name="version.number" value="1.6.5"/>
<!-- Paths within the repository that are referenced
multiple times. -->
<property name="build.apps" location="build"/>
<property name="build.splunk" location="build/splunk"/>
<property name="build.tests" location="build/tests"/>
<property name="build.examples" location="build/examples"/>
<property name="build.util" location="build/util"/>
<property name="dist" location="dist"/>
<property name="coverage.dir" location="build/reports/coverage"/>
<property name="testreport.dir" location="build/reports/tests" />
<!-- Test case to run -->
<!-- This is separated into a property so it can be overridden by command line arguments,
making it easy to run specific test cases. -->
<property name="testcase" value="*Test" />
<!-- Short names for all the external libraries that get
referenced multiple times. -->
<property name="junit" location="lib/junit-4.11.jar"/>
<property name="gson" location="lib/gson-2.2.4.jar"/>
<property name="opencsv" location="lib/opencsv-2.3.jar"/>
<target name="clean">
<delete dir="build"/>
<delete dir="dist"/>
<delete dir="out" /> <!-- IntelliJ's output directory -->
</target>
<target name="build">
<!-- Compile the SDK -->
<mkdir dir="${build.splunk}"/>
<javac includeantruntime="false"
srcdir="splunk"
destdir="${build.splunk}"
target="1.6"
source="1.6"
debug="true"
debuglevel="lines,vars,source">
<classpath>
<pathelement location="${gson}"/>
<pathelement location="${opencsv}"/>
</classpath>
</javac>
<!-- Compile utils -->
<mkdir dir="${build.util}"/>
<javac includeantruntime="false"
target="1.6"
source="1.6"
srcdir="util"
destdir="${build.util}">
<classpath>
<pathelement location="${build.splunk}"/>
<pathelement location="lib/commons-cli-1.2.jar"/>
<pathelement location="${junit}"/>
</classpath>
</javac>
<!-- Compile the unit tests -->
<mkdir dir="${build.tests}"/>
<javac includeantruntime="false"
target="1.6"
source="1.6"
srcdir="tests"
destdir="${build.tests}">
<classpath>
<pathelement location="${build.splunk}"/>
<pathelement location="${build.util}"/>
<pathelement location="${junit}"/>
<pathelement location="${gson}"/>
</classpath>
</javac>
<mkdir dir="${build.tests}/test_data"/>
<copy todir="${build.tests}/com/splunk">
<fileset dir="tests/com/splunk">
<exclude name="**/*.java"/>
</fileset>
</copy>
<!-- Compile the examples -->
<mkdir dir="${build.examples}/"/>
<javac includeantruntime="false"
target="1.6"
source="1.6"
srcdir="examples"
destdir="${build.examples}">
<classpath>
<pathelement location="${build.splunk}"/>
<pathelement location="${build.util}"/>
<pathelement location="lib/org-openide-explorer.jar"/>
<pathelement location="lib/org-openide-nodes.jar"/>
<pathelement location="lib/org-openide-util.jar"/>
<pathelement location="lib/org-openide-util-lookup.jar"/>
<pathelement location="${gson}"/>
<pathelement location="${opencsv}"/>
</classpath>
</javac>
</target>
<!-- Macro to build standalone, executable jars for the examples. Specify the
example's name and any extra dependencies it requires besides the base SDK,
utils, and commons-cli-1.2.jar.
Example:
<standalone-example-jar name="explorer">
<dependencies>
<fileset dir="${build.util}"
includes="**/*.class" />
<zipgroupfileset dir="lib" includes="gson-2.2.4.jar" />
<zipgroupfileset dir="lib" includes="opencsv-2.3.jar" />
<zipgroupfileset dir="lib" includes="org-openide-*.jar" />
</dependencies>
</standalone-example-jar>
-->
<macrodef name="standalone-example-jar">
<attribute name="name"/>
<element name="dependencies" optional="yes"/>
<sequential>
<mkdir dir="${dist}/examples"/>
<jar destfile="${dist}/examples/@{name}.jar">
<!-- The example's code -->
<fileset dir="${build.examples}"
includes="com/splunk/examples/@{name}/**/*.class"/>
<!-- Dependencies shared by all examples -->
<fileset dir="${build.util}" includes="**/*.class"/>
<fileset dir="${build.splunk}" includes="**/*.class"/>
<zipgroupfileset dir="lib" includes="commons-cli-1.2.jar"/>
<!-- Extra dependencies for this example -->
<dependencies/>
<manifest>
<attribute name="Main-Class"
value="com.splunk.examples.@{name}.Program"/>
<attribute name="Implementation-Title"
value="com.splunk.examples.@{name}"/>
<attribute name="Implementation-Vendor"
value="Splunk, Inc."/>
<attribute name="Implementation-Version"
value="${version.number}"/>
</manifest>
</jar>
</sequential>
</macrodef>
<!-- Make jar files for general distribution of the SDK. The primary one
is splunk.jar, and we create a jar for each example, including its
dependencies, to make it easily redistributable.
-->
<target name="dist" depends="build, javadoc, sources">
<mkdir dir="${dist}"/>
<!-- Splunk SDK jar -->
<jar destfile="${dist}/splunk-${version.number}.jar">
<fileset dir="${build.splunk}"
includes="**/*.class"/>
<fileset dir="${build.util}"
includes="**/Command.class"/>
<fileset dir="splunk" includes="**/*"/>
<manifest>
<attribute name="Implementation-Title"
value="com.splunk"/>
<attribute name="Implementation-Vendor"
value="Splunk, Inc."/>
<attribute name="Implementation-Version"
value="${version.number}"/>
</manifest>
</jar>
<copy file="${gson}" todir="${dist}"/>
<copy file="${opencsv}" todir="${dist}"/>
<!-- Now, the examples -->
<standalone-example-jar name="endpoint_instantiation"/>
<standalone-example-jar name="explorer">
<dependencies>
<zipgroupfileset dir="lib" includes="gson-2.2.4.jar"/>
<zipgroupfileset dir="lib" includes="opencsv-2.3.jar"/>
<zipgroupfileset dir="lib" includes="org-openide-*.jar"/>
</dependencies>
</standalone-example-jar>
<standalone-example-jar name="export"/>
<standalone-example-jar name="genevents"/>
<standalone-example-jar name="get_job"/>
<standalone-example-jar name="index"/>
<standalone-example-jar name="info"/>
<standalone-example-jar name="input"/>
<standalone-example-jar name="random_numbers"/>
<standalone-example-jar name="search">
<dependencies>
<zipgroupfileset dir="lib" includes="gson-2.2.4.jar"/>
<zipgroupfileset dir="lib" includes="opencsv-2.3.jar"/>
</dependencies>
</standalone-example-jar>
<standalone-example-jar name="search_blocking"/>
<standalone-example-jar name="search_oneshot"/>
<standalone-example-jar name="search_realtime"/>
<standalone-example-jar name="search_saved"/>
<standalone-example-jar name="search_simple"/>
<standalone-example-jar name="spurl"/>
<standalone-example-jar name="ssl_protocols"/>
<standalone-example-jar name="tail"/>
<standalone-example-jar name="pivot">
<dependencies>
<zipgroupfileset dir="lib" includes="gson-2.2.4.jar"/>
</dependencies>
</standalone-example-jar>
<standalone-example-jar name="fluent_pivot">
<dependencies>
<zipgroupfileset dir="lib" includes="gson-2.2.4.jar"/>
</dependencies>
</standalone-example-jar>
<!-- Create the random_numbers example modular input app -->
<echo message="Assembling example app"/>
<copy todir="${build.apps}/random_numbers">
<fileset dir="examples/com/splunk/examples/random_numbers/random_numbers"/>
</copy>
<mkdir dir="${build.apps}/random_numbers/jars"/>
<copy file="${dist}/examples/random_numbers.jar" todir="${build.apps}/random_numbers/jars"/>
<mkdir dir="${build.apps}/random_numbers/windows_x86_64/bin"/>
<copy file="launchers/shim-windows_x86_64.exe" tofile="${build.apps}/random_numbers/windows_x86_64/bin/random_numbers.exe"/>
<mkdir dir="${build.apps}/random_numbers/windows_x86/bin"/>
<copy file="launchers/shim-windows_x86.exe" tofile="${build.apps}/random_numbers/windows_x86/bin/random_numbers.exe"/>
<mkdir dir="${build.apps}/random_numbers/darwin_x86_64/bin"/>
<copy file="launchers/shim-darwin.sh" tofile="${build.apps}/random_numbers/darwin_x86_64/bin/random_numbers.sh"/>
<mkdir dir="${build.apps}/random_numbers/linux_x86/bin"/>
<copy file="launchers/shim-linux.sh" tofile="${build.apps}/random_numbers/linux_x86/bin/random_numbers.sh"/>
<mkdir dir="${build.apps}/random_numbers/linux_x86_64/bin"/>
<copy file="launchers/shim-linux.sh" tofile="${build.apps}/random_numbers/linux_x86_64/bin/random_numbers.sh"/>
<echo message="Packaging example app"/>
<tar longfile="gnu" destfile="${dist}/random_numbers.spl">
<tarfileset dir="${build.apps}" filemode="755">
<include name="random_numbers/*/bin/random_numbers.*"/>
</tarfileset>
<tarfileset dir="${build.apps}">
<include name="random_numbers/**"/>
<exclude name="random_numbers/*/bin/*"/>
</tarfileset>
</tar>
<echo message="Done packaging."/>
</target>
<!-- Create JavaDoc site in dist/docs/ with JavaDoc jar in dist/splunk-${version.number}-javadoc.jar -->
<!-- Javadoc is not backwards compatible with Java version 1.6. Must have Java version 1.6 to build correctly -->
<!-- http://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-7.html -->
<target name="javadoc">
<property name="dist.docs" location="${dist}/docs"/>
<mkdir dir="${dist.docs}"/>
<javadoc destdir="${dist.docs}"
sourcepath="splunk"
stylesheetfile="splunk/staticdocs.css">
<classpath>
<pathelement location="${gson}"/>
<pathelement location="${opencsv}"/>
</classpath>
</javadoc>
<jar basedir="${dist.docs}" destfile="${dist}/splunk-${version.number}-javadoc.jar">
<manifest>
<attribute name="Implementation-Title"
value="com.splunk"/>
<attribute name="Implementation-Vendor"
value="Splunk, Inc."/>
<attribute name="Implementation-Version"
value="${version.number}"/>
</manifest>
</jar>
</target>
<!-- Create sources jar, dist/splunk-${version.number}-sources.jar -->
<target name="sources">
<property name="sources" location="splunk"/>
<jar basedir="${sources}" destfile="${dist}/splunk-${version.number}-sources.jar" excludes=".classpath, .project, splunk.iml, staticdocs.css">
<manifest>
<attribute name="Implementation-Title"
value="com.splunk"/>
<attribute name="Implementation-Vendor"
value="Splunk, Inc."/>
<attribute name="Implementation-Version"
value="${version.number}"/>
</manifest>
</jar>
</target>
<!-- Run the test suite -->
<target name="test" depends="build">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed" printsummary="on">
<classpath>
<pathelement location="${build.tests}"/>
<pathelement location="${build.util}"/>
<pathelement location="lib/commons-cli-1.2.jar"/>
<pathelement location="${build.splunk}"/>
<pathelement location="${junit}"/>
<pathelement location="${gson}"/>
<pathelement location="${opencsv}"/>
</classpath>
<batchtest>
<fileset dir="${build.tests}">
<include name="**/${testcase}.class"/>
</fileset>
<formatter type="xml" />
</batchtest>
<formatter type="xml" />
<formatter type="plain" usefile="false"/>
<jvmarg value="-Dhttps.protocols=TLSv1.1,TLSv1.2"/>
</junit>
<fail message="Test failure detected, check test results." if="test.failed" />
</target>
<target name="print-version">
<echo>Java/JVM version: ${ant.java.version}</echo>
<echo>Java/JVM detail version: ${java.version}</echo>
</target>
<!-- Run the test suite -->
<target name="travis" depends="build">
<junit fork="yes" haltonfailure="no" failureproperty="test.failed" printsummary="yes" showoutput="yes">
<classpath>
<pathelement location="${build.tests}"/>
<pathelement location="${build.util}"/>
<pathelement location="lib/commons-cli-1.2.jar"/>
<pathelement location="${build.splunk}"/>
<pathelement location="${junit}"/>
<pathelement location="${gson}"/>
<pathelement location="${opencsv}"/>
</classpath>
<batchtest>
<fileset dir="${build.tests}">
<include name="**/${testcase}.class"/>
</fileset>
<formatter type="xml" />
</batchtest>
<formatter type="xml" />
<formatter type="plain" usefile="false"/>
<jvmarg value="-Dhttps.protocols=TLSv1.1,TLSv1.2"/>
</junit>
<fail message="Test failure detected, check test results." if="test.failed" />
</target>
<target name="testreport" depends="test">
<mkdir dir="${testreport.dir}"/>
<junitreport todir="${testreport.dir}">
<fileset dir=".">
<include name="TEST-*.xml" />
</fileset>
<report todir="${testreport.dir}" />
</junitreport>
</target>
<!-- Run the test suite with code coverage. -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="lib/jacocoant.jar"/>
</taskdef>
<target name="coverage" depends="build">
<delete file="${coverage.dir}/coverage_report.exec" />
<jacoco:coverage append="true" destfile="${coverage.dir}/coverage_report.exec">
<junit fork="yes" haltonfailure="no">
<classpath>
<pathelement location="${build.tests}"/>
<pathelement location="${build.util}"/>
<pathelement location="lib/commons-cli-1.2.jar"/>
<pathelement location="${build.splunk}"/>
<pathelement location="${junit}"/>
<pathelement location="${gson}"/>
<pathelement location="${opencsv}"/>
</classpath>
<batchtest>
<fileset dir="${build.tests}">
<include name="**/*Test.class"/>
</fileset>
<formatter type="xml" />
</batchtest>
<formatter type="xml" />
<formatter type="plain" usefile="false"/>
</junit>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="${coverage.dir}/coverage_report.exec" />
</executiondata>
<structure name="Splunk SDK for Java">
<classfiles>
<fileset dir="${build.splunk}" />
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="splunk" />
</sourcefiles>
</structure>
<html destdir="${coverage.dir}"/>
<xml destfile="test_coverage.xml"/>
</jacoco:report>
<mkdir dir="${testreport.dir}"/>
<junitreport todir="${testreport.dir}">
<fileset dir="${testreport.dir}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${testreport.dir}" />
</junitreport>
</target>
</project>