-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
278 lines (236 loc) · 9.62 KB
/
build.gradle
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
/**
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved.
*
* 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
*/
plugins {
id 'java'
id 'com.github.spotbugs' version '3.0.0'
id "io.franzbecker.gradle-lombok" version "3.3.0"
id "com.github.johnrengelman.shadow" version "6.1.0"
id 'jacoco'
id "org.nosphere.apache.rat" version "0.6.0"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
allprojects {
apply plugin: 'checkstyle'
apply plugin: 'io.franzbecker.gradle-lombok'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply from: "$rootDir/gradle/rat.gradle"
repositories {
jcenter()
mavenCentral()
mavenLocal()
maven {
url "https://repository.apache.org/snapshots"
}
maven {
url "https://oss.jfrog.org/jfrog-dependencies"
}
}
lombok {
version = lombokVersion
}
dependencies {
// Needed to have Lombok work with Gradle 5.x+. See https://github.com/rzwitserloot/lombok/issues/1945.
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
compileOnly("org.projectlombok:lombok:${lombokVersion}")
compile group: "org.slf4j", name: "slf4j-api", version: "${slf4jApiVersion}"
compile group: "org.apache.commons", name: "commons-lang3", version: "${commonsLangVersion}"
compile group: "ch.qos.logback", name: "logback-classic", version: "${logbackVersion}"
compile group: "org.projectlombok", name: "lombok", version: "${lombokVersion}"
compile group: "com.github.spotbugs", name: "spotbugs-annotations", version: "${spotbugsAnnotationsVersion}"
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jacksonDatabind}"
testCompile group: "junit", name: "junit", version: "${junitVersion}"
testCompile group: "org.mockito", name: "mockito-core", version: "${mockitoVersion}"
testCompile group: "org.hamcrest", name: "hamcrest-all", version: "${hamcrestVersion}"
testCompile group: "com.github.stefanbirkner", name: "system-rules", version: "${systemRulesVersion}"
}
// Delombok sources.
task delombok(type: io.franzbecker.gradle.lombok.task.DelombokTask, dependsOn: compileJava) {
ext.outputDir = file("$buildDir/delombok")
outputs.dir(outputDir)
sourceSets.main.java.srcDirs.each {
inputs.dir(it)
args(it, "-d", outputDir)
}
}
checkstyle {
toolVersion '7.8.1'
configFile file("$rootDir/config/checkstyle.xml")
}
checkstyleMain {
source ='src/main/java'
}
checkstyleTest {
source ='src/test/java'
}
// Configure Spotbugs
spotbugs {
effort = "max"
includeFilter = file("$rootDir/config/spotbugs-include.xml")
excludeFilter = file("$rootDir/config/spotbugs-exclude.xml")
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}
}
project (':kafka-adapter') {
apply plugin: 'com.github.johnrengelman.shadow' // Used to generate a fat jar with all dependencies
apply plugin: 'maven-publish' // Used to publish shadowJar generated fat jar to repo
apply plugin: 'jacoco'
group "${groupId}"
version "${versionId}"
dependencies {
compile group: "io.pravega", name: "pravega-client", version: "${pravegaVersion}"
compile group: "io.pravega", name: "pravega-common", version: "${pravegaVersion}"
compile group: "org.apache.kafka", name: "kafka_2.12", version: "${kafkaVersion}"
compile group: "org.apache.kafka", name: "kafka-clients", version: "${kafkaVersion}"
compile group: "com.github.spotbugs", name: "spotbugs-annotations", version: "${spotbugsAnnotationsVersion}"
compile group: "com.google.guava", name: "guava", version: "${guavaVersion}"
testCompile group: "org.apache.kafka", name: "kafka_2.12", version: "${kafkaVersion}", classifier: "test"
testCompile group: "org.apache.kafka", name: "kafka-streams", version: "${kafkaVersion}", classifier: "test"
testCompile group: "org.apache.kafka", name: "kafka-clients", version: "${kafkaVersion}", classifier: "test"
testCompile group: "org.apache.kafka", name: "kafka-streams-test-utils", version: "${kafkaVersion}"
}
publishing {
publications {
// Enables: `./gradlew :kafka-adapter:publishShadowPublicationToMavenLocal`
shadow(MavenPublication) {
from components.java
artifact shadowJar
pom {
name = 'Pravega Kafka Adapter'
}
}
// Enables `./gradlew :kafka-adapter:publish`
lib(MavenPublication) {
from components.java
artifact shadowJar
pom {
name = 'Pravega Kafka Adapter'
}
// Repositories to publish to.
repositories {
mavenLocal()
// For now, publish to mavenLocal() only. We'll enable publishing to Maven at a later time.
// mavenCentral()
}
}
}
}
test {
// We don't want to execute these integrations tests as unit tests. These samples/tests are meant to be run
// interactively targeting a separately running deployment.
exclude "io/pravega/adapters/kafka/client/integrationtests/**"
}
jacoco {
toolVersion = "0.8.5"
}
jacocoTestReport {
dependsOn test
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
// Enforces target code coverage by failing builds.
jacocoTestCoverageVerification {
// Run this task only if the test task is also run. So, `./gradlew build -x test` will skip this task a well,
// while it'll be run if `gradlew build` or `./gradlew check` is run.
onlyIf {
test.state.executed
}
violationRules {
rule {
limit {
// 75% code coverage is required.
minimum = 0.75
}
}
}
}
/**
* Create a fat jar with all dependencies including Kafka client in it. Here we are specifying to the shadowJar task
* that it should replace some of Kafka's classes with custom implementations that enables a Kafka client to talk to
* Pravega instead of Kafka.
*/
shadowJar {
// `./gradlew shadowJar` command will output to build/libs/${artifactId}-${versionId}-${classifierId}
baseName("${artifactId}")
// group("${groupId}")
version("${versionId}")
classifier("${classifierId}")
// Replace Kafka Producer implementation
relocate 'org.apache.kafka.clients.producer.KafkaProducer',
'org.apache.kafka.clients.producer.OriginalKafkaProducer'
relocate 'io.pravega.adapters.kafka.client.producer.PravegaKafkaProducer',
'org.apache.kafka.clients.producer.KafkaProducer'
// Replace Kafka Consumer implementation
relocate 'org.apache.kafka.clients.consumer.KafkaConsumer',
'org.apache.kafka.clients.consumer.OriginalKafkaConsumer'
relocate 'io.pravega.adapters.kafka.client.consumer.PravegaKafkaConsumer',
'org.apache.kafka.clients.consumer.KafkaConsumer'
// ----------------------------------------------------------------------------
// The following are needed for Flink Kafka Connector's usage of this adapter
// ----------------------------------------------------------------------------
// Replace byte array deserializer.
relocate 'org.apache.kafka.common.serialization.ByteArrayDeserializer',
'org.apache.kafka.common.serialization.OriginalByteArrayDeserializer'
relocate 'io.pravega.adapters.kafka.client.shared.ByteArraySerializer',
'org.apache.kafka.common.serialization.ByteArrayDeserializer'
}
tasks.build.dependsOn tasks.shadowJar
tasks.check.dependsOn jacocoTestCoverageVerification
// We don't want the un-shadowed jar kafka-adapter-<version>.jar (without the classifer `all`) containing only the
// classes of this project. If we modify the following to true, we'd see
// `kafka-adapter\build\libs\kafka-adapter-<version>.jar` getting produced upon build (`./gradlew build`).
jar.enabled = false
}
project (':kafka-adapter-samples') {
dependencies {
// Kafka dependencies
// compile group: "org.apache.kafka", name: "kafka_2.13", version: "${kafkaVersion}"
// compile group: "org.apache.kafka", name: "kafka-clients", version: "${kafkaVersion}"
// Kafka adapter dependency that replaces KafkaProducer and KafkaConsumer under the hoods.
// The below dependency can be used to simulate the exact changed by the kafa applications
// compile group: "io.pravega.adapters.kafka-adapter", name: "kafka-adapter", version: "1.0-SNAPSHOT", classifier: "all"
// This ensures we depend on the same shadow jar similar to the above line with the change that it is
// dynamically generated by gradle for us.
compile project(path: ':kafka-adapter', configuration: 'shadow')
}
}
project (':kafka-adapter-samples:flink-kafka-connector-samples') {
apply plugin: "scala"
dependencies {
// Set 1 (to Pravega)
compile ("org.apache.flink:flink-connector-kafka_${flinkScalaVersion}:${flinkVersion}") {
exclude group: "org.apache.kafka", module: "kafka-clients"
}
// Kafka adapter dependency that replaces KafkaProducer and KafkaConsumer under the hoods.
// The below dependency can be used to simulate the exact changed by the kafa applications
// compile "io.pravega.adapters.kafka-adapter:kafka-adapter:1.0-SNAPSHOT:all"
// This ensures we depend on the same shadow jar similar to the above line with the change that it is
// dynamically generated by gradle for us.
compile project(path: ':kafka-adapter', configuration: 'shadow')
/*
// Set 2 (To Kafka)
compile "org.apache.flink:flink-connector-kafka_${flinkScalaVersion}:${flinkVersion}"
compile group: "io.pravega", name: "pravega-client", version: "${pravegaVersion}"
*/
compile group: "io.pravega", name: "pravega-common", version: "${pravegaVersion}"
compile "org.apache.flink:flink-streaming-java_${flinkScalaVersion}:${flinkVersion}"
compile "org.apache.flink:flink-streaming-scala_${flinkScalaVersion}:${flinkVersion}"
}
}