github.com/apache/beam/sdks/v2@v2.48.2/java/io/kafka/build.gradle (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * License); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an AS IS BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 import java.util.stream.Collectors 20 21 plugins { id 'org.apache.beam.module' } 22 applyJavaNature( 23 automaticModuleName: 'org.apache.beam.sdk.io.kafka', 24 mavenRepositories: [ 25 [id: 'io.confluent', url: 'https://packages.confluent.io/maven/'] 26 ], 27 ) 28 provideIntegrationTestingDependencies() 29 enableJavaPerformanceTesting() 30 31 description = "Apache Beam :: SDKs :: Java :: IO :: Kafka" 32 ext.summary = "Library to read Kafka topics." 33 34 def kafkaVersions = [ 35 '01103': "0.11.0.3", 36 '100': "1.0.0", 37 '111': "1.1.1", 38 '201': "2.0.1", 39 '211': "2.1.1", 40 '222': "2.2.2", 41 '231': "2.3.1", 42 '241': "2.4.1", 43 '251': "2.5.1", 44 ] 45 46 kafkaVersions.each{k,v -> configurations.create("kafkaVersion$k")} 47 48 dependencies { 49 implementation library.java.vendored_guava_26_0_jre 50 provided library.java.jackson_dataformat_csv 51 permitUnusedDeclared library.java.jackson_dataformat_csv 52 implementation project(path: ":sdks:java:core", configuration: "shadow") 53 implementation project(":sdks:java:extensions:avro") 54 implementation project(":runners:core-construction-java") 55 implementation project(":sdks:java:expansion-service") 56 permitUnusedDeclared project(":sdks:java:expansion-service") // BEAM-11761 57 implementation library.java.avro 58 // Get back to "provided" since 2.14 59 provided library.java.kafka_clients 60 testImplementation library.java.kafka_clients 61 implementation library.java.slf4j_api 62 implementation library.java.joda_time 63 implementation library.java.jackson_annotations 64 implementation library.java.jackson_databind 65 implementation "org.springframework:spring-expression:5.3.25" 66 implementation ("io.confluent:kafka-avro-serializer:5.3.2") { 67 // zookeeper depends on "spotbugs-annotations:3.1.9" which clashes with current 68 // "spotbugs-annotations:3.1.12" used in Beam. Not required. 69 exclude group: "org.apache.zookeeper", module: "zookeeper" 70 // "kafka-clients" has to be provided since user can use its own version. 71 exclude group: "org.apache.kafka", module: "kafka-clients" 72 } 73 implementation ("io.confluent:kafka-schema-registry-client:5.3.2") { 74 // It depends on "spotbugs-annotations:3.1.9" which clashes with current 75 // "spotbugs-annotations:3.1.12" used in Beam. Not required. 76 exclude group: "org.apache.zookeeper", module: "zookeeper" 77 // "kafka-clients" has to be provided since user can use its own version. 78 exclude group: "org.apache.kafka", module: "kafka-clients" 79 } 80 // everit_json is needed for Kafka Read SchemaTransform tests that rely on JSON-schema translation. 81 permitUnusedDeclared library.java.everit_json_schema 82 provided library.java.everit_json_schema 83 testImplementation project(path: ":sdks:java:core", configuration: "shadowTest") 84 testImplementation project(":sdks:java:io:synthetic") 85 testImplementation project(":sdks:java:extensions:avro") 86 testImplementation project(path: ":sdks:java:io:common", configuration: "testRuntimeMigration") 87 testImplementation project(path: ":sdks:java:testing:test-utils", configuration: "testRuntimeMigration") 88 // For testing Cross-language transforms 89 testImplementation project(":runners:core-construction-java") 90 testImplementation library.java.avro 91 testImplementation library.java.junit 92 testImplementation library.java.powermock 93 testImplementation library.java.powermock_mockito 94 testImplementation library.java.testcontainers_kafka 95 testRuntimeOnly library.java.slf4j_jdk14 96 testRuntimeOnly project(path: ":runners:direct-java", configuration: "shadow") 97 kafkaVersions.each {"kafkaVersion$it.key" "org.apache.kafka:kafka-clients:$it.value"} 98 } 99 100 kafkaVersions.each { kv -> 101 configurations."kafkaVersion$kv.key" { 102 resolutionStrategy { 103 force "org.apache.kafka:kafka-clients:$kv.value" 104 } 105 } 106 } 107 108 kafkaVersions.each {kv -> 109 task "kafkaVersion${kv.key}Test"(type: Test) { 110 group = "Verification" 111 description = "Runs KafkaIO tests with Kafka clients API $kv.value" 112 outputs.upToDateWhen { false } 113 testClassesDirs = sourceSets.test.output.classesDirs 114 classpath = configurations."kafkaVersion${kv.key}" + sourceSets.test.runtimeClasspath 115 include '**/KafkaIOTest.class' 116 } 117 } 118 119 //Because this runs many integration jobs in parallel, each of which use a 120 //container, it can fail locally due to performance limitations on a desktop. 121 //To avoid this, use --max-workers=N, where N is less than half your CPUs. 122 //4 is a good start for parallelism without overloading your computer. 123 task kafkaVersionsCompatibilityTest { 124 group = "Verification" 125 description = 'Runs KafkaIO with different Kafka client APIs' 126 def testNames = createTestList(kafkaVersions, "Test") 127 dependsOn testNames 128 dependsOn (":sdks:java:io:kafka:kafka-01103:kafkaVersion01103BatchIT") 129 dependsOn (":sdks:java:io:kafka:kafka-100:kafkaVersion100BatchIT") 130 dependsOn (":sdks:java:io:kafka:kafka-111:kafkaVersion111BatchIT") 131 dependsOn (":sdks:java:io:kafka:kafka-201:kafkaVersion201BatchIT") 132 dependsOn (":sdks:java:io:kafka:kafka-211:kafkaVersion211BatchIT") 133 dependsOn (":sdks:java:io:kafka:kafka-222:kafkaVersion222BatchIT") 134 dependsOn (":sdks:java:io:kafka:kafka-231:kafkaVersion231BatchIT") 135 dependsOn (":sdks:java:io:kafka:kafka-241:kafkaVersion241BatchIT") 136 dependsOn (":sdks:java:io:kafka:kafka-251:kafkaVersion251BatchIT") 137 } 138 139 static def createTestList(Map<String, String> prefixMap, String suffix) { 140 return prefixMap.keySet().stream() 141 .map{version -> "kafkaVersion${version}${suffix}"} 142 .collect(Collectors.toList()) 143 }