forked from opendxl/opendxl-databus-client-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
340 lines (306 loc) · 10.3 KB
/
build.gradle
File metadata and controls
340 lines (306 loc) · 10.3 KB
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
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
}
dependencies {
classpath 'org.owasp:dependency-check-gradle:6.1.5'
}
}
plugins {
id 'checkstyle'
id 'distribution'
id 'java-library'
id 'maven-publish'
id 'signing'
id "com.github.johnrengelman.shadow" version "4.0.3"
id "kr.motd.sphinx" version "2.3.1"
id "jacoco"
id "org.owasp.dependencycheck" version "6.1.5"
}
group 'com.opendxl'
sourceCompatibility = 1.8
apply plugin: 'base'
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
suppressionFile = file("${projectDir}/config/dependency-check/owasp-suppression.xml")
}
jacoco {
toolVersion = "0.8.6"
reportsDir = file("$buildDir/reports/coverage")
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("$buildDir/reports/coverage")
}
}
configurations {
kafkaInMemory
sampleJars.extendsFrom testImplementation
}
dependencies {
implementation ('org.apache.kafka:kafka-clients:2.3.1') {
exclude group: 'org.scala-lang', module: 'scala-reflect'
exclude group: 'org.lz4', module: 'lz4-java'
}
implementation ('org.apache.kafka:kafka-streams:2.3.1') {
exclude group: 'org.scala-lang', module: 'scala-reflect'
}
implementation 'org.scala-lang:scala-reflect:2.12.11'
implementation 'org.lz4:lz4-java:1.7.1'
implementation 'org.apache.avro:avro:1.11.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.apache.commons:commons-configuration2:2.7'
implementation 'commons-lang:commons-lang:2.6'
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
testImplementation('org.apache.kafka:kafka_2.12:2.3.1') {
exclude group: 'org.scala-lang', module: 'scala-reflect'
}
testImplementation 'org.scala-lang:scala-reflect:2.12.11'
testImplementation 'org.apache.zookeeper:zookeeper:3.5.7'
testImplementation('io.netty:netty-all:4.1.43.Final') {
force = true
}
testImplementation 'commons-io:commons-io:2.7'
testImplementation 'junit:junit:4.12'
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
testImplementation 'com.e-movimento.tinytools:privilegedaccessor:1.2.2'
kafkaInMemory ('org.apache.kafka:kafka_2.12:2.3.1') {
exclude group: 'org.scala-lang', module: 'scala-reflect'
exclude group: 'org.lz4', module: 'lz4-java'
}
kafkaInMemory 'org.scala-lang:scala-reflect:2.12.11'
kafkaInMemory 'org.lz4:lz4-java:1.7.1'
kafkaInMemory 'commons-io:commons-io:2.7'
// This following section mitigates OWASP vulnerabilities report.
// It enforces to use specific transitive dependency versions
// when their previous versions were mentioned by OWASP vulnerability reports.
// If a vulnerability is false-positive,
// libraries should be declared in /config/dependency-check/owasp-supression.xml
// https://nvd.nist.gov/vuln/detail/CVE-2019-12384
// https://nvd.nist.gov/vuln/detail/CVE-2019-12814
// https://nvd.nist.gov/vuln/detail/CVE-2019-14379
// https://nvd.nist.gov/vuln/detail/CVE-2019-14439
// http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-14540
// http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-16335
// http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-16942
// http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-16943
// CVE-2020-25649
compile ('com.fasterxml.jackson.core:jackson-databind:2.13.2.2') {
force = true
}
kafkaInMemory ('com.fasterxml.jackson.core:jackson-databind:2.13.2.2') {
force = true
}
// http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-12402
kafkaInMemory ('org.apache.commons:commons-compress:1.21') {
force = true
}
compile ('org.apache.commons:commons-compress:1.21') {
force = true
}
}
repositories {
mavenCentral()
}
// Jar Manifest info
jar {
manifest {
attributes('Main-Class': 'com.opendxl.databus.cli.CommandLineInterface',
'Implementation-Title': rootProject.name,
'Implementation-Version': rootProject.name
)
}
}
// Task for creating a jar with the source files
task sourceJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
// Task for creating a jar with JavaDoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
exclude "**/broker/**"
options.memberLevel = JavadocMemberLevel.PUBLIC
}
artifacts {
archives jar
archives sourceJar
archives javadocJar
}
// Set up the distribution zip
distributions {
main {
baseName = 'dxldatabusclient-java-sdk'
contents {
from(jar) {
into('lib')
}
from(shadowJar) {
into("lib")
}
from(configurations.sampleJars) {
into("sample/lib")
}
from(configurations.compileClasspath) {
into("lib/3rdparty")
}
from(sphinx) {
into('doc')
}
from('sample') {
into 'sample'
}
from('broker/src/broker') {
into 'sample/src/broker'
}
from(shadowJar) {
into("sample/lib")
}
from(configurations.kafkaInMemory) {
into("sample/lib/kafka")
}
from('distribution')
}
}
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/java'
}
compileClasspath += configurations.kafkaInMemory
runtimeClasspath += configurations.kafkaInMemory
}
sample {
java {
srcDir 'sample/src'
srcDir 'broker/src'
}
resources {
srcDir 'sample/src'
}
compileClasspath += main.output + test.output + configurations.compileClasspath + configurations.kafkaInMemory
runtimeClasspath += main.output + test.output + configurations.runtimeClasspath + configurations.kafkaInMemory
}
test {
java {
srcDir 'src/test/java'
srcDir 'broker/src'
}
resources {
srcDir 'src/test/resources'
}
}
}
// Make check style run before creating a jar
jar.dependsOn(checkstyleMain)
// Force distZip to be dependent on javadocJar and sourceJar
distZip.dependsOn javadocJar
distZip.dependsOn sourceJar
sphinx {
// Change the source directory.
sourceDirectory = "${projectDir}/docs"
// Change the output directory.
outputDirectory = "${project.buildDir}/docs"
}
task versionFile() {
doLast {
new File("${projectDir}/VERSION").text = """$version"""
}
}
checkstyle {
sourceSets = []
toolVersion '8.39'
}
publishing {
publications {
maven(MavenPublication) {
groupId = group
pom {
name = 'OpenDXL Databus Java Client'
description = 'An OpenDXL Databus client library for Java'
url = 'https://github.com/opendxl/opendxl-databus-client-java'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
email = 'support@opendxl.com'
}
}
scm {
connection = 'scm:git:git://github.com/opendxl/opendxl-databus-client-java.git'
developerConnection = 'scm:git:ssh://github.com/opendxl/opendxl-databus-client-java.git'
url = 'https://github.com/opendxl/opendxl-databus-client-java'
}
}
from components.java
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
}
}
repositories {
maven {
url = "$buildDir/repo"
// def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
// def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
// credentials {
// username sonatypeUsername
// password sonatypePassword
// }
}
}
}
task replaceVersionInREADME() {
if (!version.endsWith('SNAPSHOT')) {
// Maven
ant.replaceregexp(match: '<version>(.+)</version>', replace: "<version>${version}</version>", flags: 'g', byline: true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(match: '<version>(.+)</version>', replace: "<version>${version}</version>", flags: 'g', byline: true) {
fileset(dir: 'docs', includes: 'index.rst')
}
// Gradle
ant.replaceregexp(match: "com\\.opendxl\\:dxldatabusclient\\:(.+)", replace: "com.opendxl:dxldatabusclient:${version}'", flags: 'g', byline: true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(match: "com\\.opendxl\\:dxldatabusclient\\:(.+)", replace: "com.opendxl:dxldatabusclient:${version}'", flags: 'g', byline: true) {
fileset(dir: 'docs', includes: 'index.rst')
}
// Command Line (Docs)
ant.replaceregexp(match: "dxldatabusclient-(.*).jar", replace: "dxldatabusclient-${version}.jar", flags: 'g', byline: true) {
fileset(dir: 'docs', includes: 'CLI-Example.rst')
}
}
}
signing {sign publishing.publications.maven}
check.dependsOn dependencyCheckAnalyze
distZip.dependsOn javadocJar
distZip.dependsOn sourceJar
sphinx.dependsOn(versionFile)
assemble.dependsOn(replaceVersionInREADME)