You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Splunk Software Development Kit (SDK) for Java contains library code and
7
7
examples designed to enable developers to build applications using Splunk.
@@ -40,40 +40,15 @@ Here's what you need to get going with the Splunk SDK for Java.
40
40
If you haven't already installed Splunk, download it
41
41
[here](http://www.splunk.com/download). For more about installing and running
42
42
Splunk and system requirements, see
43
-
[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 7.0 and 7.2.
43
+
[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 8.0 and 8.2.0.
44
44
45
45
#### Splunk SDK for Java
46
46
47
47
[Get the Splunk SDK for Java](http://dev.splunk.com/view/SP-CAAAECN)—download the SDK as a ZIP, then extract the files and build the SDK. Or, download the JAR and add it to your project.
48
48
49
49
If you want to contribute to the SDK, clone the repository from [GitHub](https://github.com/splunk/splunk-sdk-java).
50
50
51
-
52
-
#### Java and Ant
53
-
54
-
You'll need Java version 8 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v8 and v11.
55
-
56
-
You'll also need Ant, which you can install from the
The Splunk SDK for Java is compatible with Java 8. Be aware that **Java 8 disables Secure Sockets Layer version 3 (SSLv3) by default**, so you will need to use Transport Layer Security (TLS) instead. To see an example of how to do this, see the [`ssl_protocols`](https://github.com/splunk/splunk-sdk-java/blob/master/examples/com/splunk/examples/ssl_protocols/Pro...) example. Alternatively, you can re-enable SSLv3 in Java settings, but this is not recommended.
60
-
61
-
If you are using Windows, you'll need to make sure the following system
62
-
variables are created and set:
63
-
64
-
***ANT_HOME** should be set to the location where Ant is installed.
65
-
66
-
***JAVA_HOME** should be set to the directory where the JDK is installed.
67
-
68
-
***PATH** should include the path to the **%ANT_HOME%\bin** directory.
69
-
70
-
For full installation instructions, you can find more information here:
You can use [Apache Maven](http://maven.apache.org/) to build your Splunk SDK for Java projects. With a few updates to your project's `pom.xml` file, it will retrieve all necessary dependencies and seamlessly build your project.
79
54
@@ -100,42 +75,43 @@ To add the Splunk SDK for Java `.JAR` file as a dependency:
100
75
<dependency>
101
76
<groupId>com.splunk</groupId>
102
77
<artifactId>splunk</artifactId>
103
-
<version>1.6.4.0</version>
78
+
<version>1.7.0</version>
104
79
</dependency>
105
80
</dependencies>
106
81
```
107
82
108
83
Be sure to update the version number to match the version of the Splunk SDK for Java that you are using.
109
84
110
-
> Note: You can make similar changes to use [Ivy](http://ant.apache.org/ivy/history/latest-milestone/tutorial/start.html) or [Gradle](http://www.gradle.org/) as well.
85
+
> Note: You can make similar changes to use [Gradle](http://www.gradle.org/) as well.
111
86
112
87
### Building the SDK and documentation
113
88
114
89
To build the SDK, open a command prompt in the **/splunk-sdk-java**
115
90
directory and enter:
116
91
117
-
ant
92
+
mvn
118
93
119
94
or
120
95
121
-
ant dist
96
+
mvn package
122
97
123
98
This command builds all of the .class and .jar files. If you just want to build
124
99
the .class files, enter:
125
100
126
-
ant build
101
+
mvn compile
127
102
128
103
To remove all build artifacts from the repository, enter:
129
104
130
-
ant clean
105
+
mvn clean
131
106
132
-
To build the documentation for the SDK, enter:
107
+
To build the documentation for the SDK, it is being automatically generated with <b>mvn package</b>, otherwise enter:
133
108
134
-
ant javadoc
109
+
cd splunk
110
+
mvn javadoc:javadoc
135
111
136
-
### Examples and unit tests
112
+
### Unit tests
137
113
138
-
The Splunk SDK for Java includes several examples and unit tests that are run at
114
+
The Splunk SDK for Java includes several unit tests that are run at
139
115
the command line.
140
116
141
117
#### Set up the .splunkrc file
@@ -187,56 +163,24 @@ shouldn't be used for storing user credentials for production. And, if you're
187
163
at all concerned about the security of your credentials, just enter them at
188
164
the command line rather than saving them in this file.
189
165
190
-
191
-
#### Run examples
192
-
193
-
After you build the SDK, examples are put in the **/splunk-sdk-
194
-
java/dist/examples** directory. To run the examples, run the Java interpreter
195
-
at the command line using the `-jar` flag to specify the target example jar
196
-
file, and include any arguments that are required by the example. To get help
197
-
for an example, use the `--help` argument with an example.
198
-
199
-
For example, to see the command-line arguments for the Search example, open a
200
-
command prompt in the **/splunk-sdk-java** directory and enter:
201
-
202
-
java -jar dist/examples/search.jar --help
203
-
204
-
To run the Search example, open a command prompt in the **/splunk-sdk-java**
205
-
directory and enter:
206
-
207
-
java -jar dist/examples/search.jar "search * | head 10" --output_mode=csv
208
-
209
-
There is also a helper script called run in the root of the repository that
210
-
simplifies running the SDK examples. For example, on Mac OS X you could
211
-
simply enter:
212
-
213
-
./run search "search * | head 10" --output_mode=csv
214
-
215
-
All the the example jars are completely self contained. They can be used
216
-
completely independently of the SDK's repository.
217
-
218
166
#### Run unit tests
219
167
220
168
To run the SDK unit tests, open a command prompt in the **/splunk-sdk-java**
221
169
directory and enter:
222
170
223
-
ant test
224
-
225
-
To run the units from anywhere in the repository, enter:
171
+
mvn test
226
172
227
-
ant test -find
228
-
229
-
You can also run specific test classes by passing the class to the -Dtestcase=
173
+
You can also run specific test classes by passing the class to the -Dtest=
230
174
option, e.g.,
231
175
232
-
ant test -Dtestcase=AtomFeedTest
176
+
mvn test -Dtest=AtomFeedTest
233
177
234
-
The ant configuration can also produce a single HTML report of all the tests run
235
-
using the target testreport (which also understands the -Dtestcase= option), e.g.
178
+
The maven configuration can also produce an HTML report of all the tests automatically when **mvn package / mvn test** are executed.
179
+
Alternate way to generate report is using below command under splunk directory:
236
180
237
-
ant testreport
181
+
mvn jacoco:report
238
182
239
-
The report will be written in build/reports/tests/index.html.
183
+
The report will be written in **/splunk-sdk-java/splunk/target/site/surefire-report.html**.
240
184
241
185
It's also possible to run the units within Java IDEs such as IntelliJ and
242
186
Eclipse. For example, to open the Splunk SDK for Java project in Eclipse:
@@ -249,17 +193,12 @@ Eclipse. For example, to open the Splunk SDK for Java project in Eclipse:
249
193
250
194
#### Measure code coverage
251
195
252
-
To measure the code coverage of the test suite, open a
253
-
command prompt in the **/splunk-sdk-java** directory and enter:
254
-
255
-
ant coverage
256
-
257
-
To run code coverage from anywhere in the repository, enter:
196
+
Measurement of code coverage is generated along with <b>mvn package / mvn test</b>:
258
197
259
-
ant coverage -find
198
+
mvn jacoco:report
260
199
261
200
To view the coverage report, open
262
-
**/splunk-sdk-java/build/reports/coverage/index.html** in your web browser.
201
+
**/splunk-sdk-java/splunk/target/test-report/index.html** in your web browser.
263
202
264
203
## Repository
265
204
@@ -271,41 +210,21 @@ ouputs</td>
271
210
</tr>
272
211
273
212
<tr>
274
-
<td><b>/build</b></td>
213
+
<td><b>/splunk/target</b></td>
275
214
<td>This directory is created by the build and contains intermediate build
276
215
ouputs</td>
277
216
</tr>
278
217
279
218
<tr>
280
-
<td><b>/dist</b></td>
281
-
<td>This directory is created by the build and contains final build
282
-
outputs</td>
283
-
</tr>
284
-
285
-
<tr>
286
-
<td><b>/examples</b></td>
287
-
<td>Examples demonstrating various SDK features</td>
288
-
</tr>
289
-
290
-
<tr>
291
-
<td><b>/lib</b></td>
292
-
<td>Third-party libraries used by examples and unit tests</td>
0 commit comments