-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathbuild.gradle
More file actions
149 lines (138 loc) · 6.69 KB
/
Copy pathbuild.gradle
File metadata and controls
149 lines (138 loc) · 6.69 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
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
import java.util.stream.Collectors
plugins { id 'org.apache.beam.module' }
applyJavaNature(
automaticModuleName: 'org.apache.beam.sdk.io.kafka',
mavenRepositories: [
[id: 'io.confluent', url: 'https://packages.confluent.io/maven/']
],
)
provideIntegrationTestingDependencies()
enableJavaPerformanceTesting()
description = "Apache Beam :: SDKs :: Java :: IO :: Kafka"
ext {
summary = "Library to read Kafka topics."
// newer versions e.g. 7.6.* require dropping support for older kafka versions.
confluentVersion = "7.5.5"
}
def kafkaVersions = [
'391': "3.9.1",
]
kafkaVersions.each{k,v -> configurations.create("kafkaVersion$k")}
dependencies {
implementation library.java.vendored_guava_32_1_2_jre
provided library.java.jackson_dataformat_csv
permitUnusedDeclared library.java.jackson_dataformat_csv
implementation project(path: ":sdks:java:core", configuration: "shadow")
implementation project(path: ":model:pipeline", configuration: "shadow")
implementation project(":sdks:java:extensions:avro")
implementation project(":sdks:java:extensions:protobuf")
implementation project(":sdks:java:expansion-service")
permitUnusedDeclared project(":sdks:java:expansion-service") // BEAM-11761
implementation library.java.avro
// Get back to "provided" since 2.14
provided library.java.kafka_clients
if (JavaVersion.current().compareTo(JavaVersion.VERSION_21) >= 0) {
// this dependency is a provided dependency for kafka-avro-serializer. It is not needed to compile with Java<=17
// but needed for compile only under Java21, specifically, required for extending from AbstractKafkaAvroDeserializer
compileOnly library.java.kafka
}
testImplementation library.java.kafka_clients
testImplementation project(path: ":runners:core-java")
implementation library.java.slf4j_api
implementation library.java.joda_time
implementation library.java.jackson_annotations
implementation library.java.jackson_databind
implementation (group: 'com.google.cloud.hosted.kafka', name: 'managed-kafka-auth-login-handler', version: '1.0.5') {
// "kafka-clients" has to be provided since user can use its own version.
exclude group: 'org.apache.kafka', module: 'kafka-clients'
// "kafka-schema-registry-client must be excluded per the Google Cloud documentation:
// https://cloud.google.com/managed-service-for-apache-kafka/docs/quickstart-avro#configure_and_run_the_producer
exclude group: "io.confluent", module: "kafka-schema-registry-client"
}
implementation ("io.confluent:kafka-avro-serializer:${confluentVersion}") {
// zookeeper depends on "spotbugs-annotations:3.1.9" which clashes with current
// "spotbugs-annotations:3.1.12" used in Beam. Not required.
exclude group: "org.apache.zookeeper", module: "zookeeper"
// "kafka-clients" has to be provided since user can use its own version.
exclude group: "org.apache.kafka", module: "kafka-clients"
}
implementation ("io.confluent:kafka-schema-registry-client:${confluentVersion}") {
// It depends on "spotbugs-annotations:3.1.9" which clashes with current
// "spotbugs-annotations:3.1.12" used in Beam. Not required.
exclude group: "org.apache.zookeeper", module: "zookeeper"
// "kafka-clients" has to be provided since user can use its own version.
exclude group: "org.apache.kafka", module: "kafka-clients"
}
// everit_json is needed for Kafka Read SchemaTransform tests that rely on JSON-schema translation.
permitUnusedDeclared library.java.everit_json_schema
provided library.java.everit_json_schema
testImplementation project(path: ":sdks:java:core", configuration: "shadowTest")
testImplementation project(":sdks:java:io:synthetic")
testImplementation project(":sdks:java:managed")
testImplementation project(path: ":sdks:java:extensions:avro", configuration: "testRuntimeMigration")
testImplementation project(path: ":sdks:java:extensions:protobuf", configuration: "testRuntimeMigration")
testImplementation project(path: ":sdks:java:io:common")
testImplementation project(path: ":sdks:java:testing:test-utils")
// For testing Cross-language transforms
testImplementation library.java.avro
testImplementation library.java.junit
testImplementation library.java.mockito_core
testRuntimeOnly library.java.mockito_inline
testImplementation library.java.testcontainers_kafka
testRuntimeOnly library.java.slf4j_jdk14
testRuntimeOnly project(path: ":runners:direct-java", configuration: "shadow")
kafkaVersions.each {"kafkaVersion$it.key" "org.apache.kafka:kafka-clients:$it.value"}
}
kafkaVersions.each { kv ->
configurations."kafkaVersion$kv.key" {
resolutionStrategy {
force "org.apache.kafka:kafka-clients:$kv.value"
}
}
}
kafkaVersions.each {kv ->
task "kafkaVersion${kv.key}Test"(type: Test) {
group = "Verification"
description = "Runs KafkaIO tests with Kafka clients API $kv.value"
outputs.upToDateWhen { false }
testClassesDirs = sourceSets.test.output.classesDirs
classpath = configurations."kafkaVersion${kv.key}" + sourceSets.test.runtimeClasspath
systemProperty "beam.target.kafka.version", kv.value
include '**/KafkaIOTest.class'
}
}
//Because this runs many integration jobs in parallel, each of which use a
//container, it can fail locally due to performance limitations on a desktop.
//To avoid this, use --max-workers=N, where N is less than half your CPUs.
//4 is a good start for parallelism without overloading your computer.
task kafkaVersionsCompatibilityTest {
group = "Verification"
description = 'Runs KafkaIO with different Kafka client APIs'
def testNames = createTestList(kafkaVersions, "Test")
dependsOn testNames
kafkaVersions.keySet().each {
dependsOn (":sdks:java:io:kafka:kafka-${it}:kafkaVersion${it}BatchIT")
}
}
static def createTestList(Map<String, String> prefixMap, String suffix) {
return prefixMap.keySet().stream()
.map{version -> "kafkaVersion${version}${suffix}"}
.collect(Collectors.toList())
}