forked from ClickHouse/clickhouse-kafka-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
260 lines (221 loc) · 9.68 KB
/
build.gradle.kts
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
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.4.2/samples
* This project uses @Incubating APIs which are subject to change.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.ByteArrayOutputStream
import java.net.URI
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
val defaultJdkVersion = 17
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
buildscript {
repositories {
mavenCentral()
}
}
plugins {
idea
`java-library`
`maven-publish`
signing
// checkstyle
id("com.github.gmazzo.buildconfig") version "5.3.5"
//id("com.github.spotbugs") version "4.7.9"
id("com.diffplug.spotless") version "6.25.0"
id("com.github.johnrengelman.shadow") version "7.1.2"
}
group = "com.clickhouse.kafka"
version = file("VERSION").readText().trim()
description = "The official ClickHouse Apache Kafka Connect Connector."
repositories {
mavenCentral()
maven("https://packages.confluent.io/maven/")
maven("https://jitpack.io")
}
extra.apply {
set("clickHouseDriverVersion", "0.6.0-patch4")
set("kafkaVersion", "2.7.0")
set("avroVersion", "1.9.2")
// Testing dependencies
set("junitJupiterVersion", "5.9.2")
set("junitPlatformVersion", "1.8.1")
set("hamcrestVersion", "2.2")
set("mockitoVersion", "4.0.0")
// Integration test dependencies
set("confluentVersion", "6.0.1")
set("scalaVersion", "2.13")
set("curatorVersion", "2.9.0")
set("connectUtilsVersion", "0.4+")
}
val clickhouseDependencies: Configuration by configurations.creating
dependencies {
implementation("org.apache.kafka:connect-api:${project.extra["kafkaVersion"]}")
implementation("com.clickhouse:clickhouse-client:${project.extra["clickHouseDriverVersion"]}")
implementation("com.clickhouse:clickhouse-http-client:${project.extra["clickHouseDriverVersion"]}")
implementation("com.clickhouse:clickhouse-data:${project.extra["clickHouseDriverVersion"]}")
implementation("io.lettuce:lettuce-core:6.3.2.RELEASE")
implementation("com.google.code.gson:gson:2.11.0")
// https://mvnrepository.com/artifact/org.apache.httpcomponents.client5/httpclient5
implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1")
// https://mvnrepository.com/artifact/com.google.guava/guava
implementation("com.google.guava:guava:33.2.1-jre")
// Avoid telescoping constructors problem with the builder pattern using Lombok
compileOnly("org.projectlombok:lombok:1.18.32")
annotationProcessor("org.projectlombok:lombok:1.18.32")
// To parse JSON response from ClickHouse to parse complex data types correctly
implementation("com.fasterxml.jackson.core:jackson-core:2.17.1")
implementation("com.fasterxml.jackson.core:jackson-databind:2.17.1")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.17.1")
// TODO: need to remove ???
implementation("org.slf4j:slf4j-reload4j:2.0.13")
implementation("org.junit.jupiter:junit-jupiter-api:5.10.2")
implementation("org.testcontainers:testcontainers:1.19.8")
implementation("org.testcontainers:toxiproxy:1.19.8")
/*
Will in side the Confluent Archive
*/
clickhouseDependencies("org.apache.httpcomponents.client5:httpclient5:5.3.1")
clickhouseDependencies("io.lettuce:lettuce-core:6.3.2.RELEASE")
clickhouseDependencies("com.clickhouse:clickhouse-client:${project.extra["clickHouseDriverVersion"]}")
clickhouseDependencies("com.clickhouse:clickhouse-http-client:${project.extra["clickHouseDriverVersion"]}")
clickhouseDependencies("com.google.code.gson:gson:2.11.0")
clickhouseDependencies("com.fasterxml.jackson.core:jackson-core:2.17.1")
clickhouseDependencies("com.fasterxml.jackson.core:jackson-databind:2.17.1")
clickhouseDependencies("com.fasterxml.jackson.core:jackson-annotations:2.17.1")
// Unit Tests
testImplementation(platform("org.junit:junit-bom:${project.extra["junitJupiterVersion"]}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit.platform:junit-platform-runner")
testImplementation("org.apiguardian:apiguardian-api:1.1.2") // https://github.com/gradle/gradle/issues/18627
testImplementation("org.hamcrest:hamcrest:${project.extra["hamcrestVersion"]}")
testImplementation("org.mockito:mockito-junit-jupiter:${project.extra["mockitoVersion"]}")
// IntegrationTests
testImplementation("org.testcontainers:clickhouse:1.19.8")
testImplementation("org.testcontainers:kafka:1.19.8")
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation("org.json:json:20240303")
testImplementation("org.testcontainers:toxiproxy:1.19.8")
testImplementation("org.apache.httpcomponents.client5:httpclient5:5.3.1")
testImplementation("com.clickhouse:clickhouse-jdbc:${project.extra["clickHouseDriverVersion"]}:all")
testImplementation("com.clickhouse:clickhouse-client:${project.extra["clickHouseDriverVersion"]}")
testImplementation("com.clickhouse:clickhouse-http-client:${project.extra["clickHouseDriverVersion"]}")
}
sourceSets.create("integrationTest") {
java.srcDir("src/integrationTest/java")
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
runtimeClasspath += output + compileClasspath + sourceSets["test"].runtimeClasspath
}
tasks.create("integrationTest", Test::class.java) {
description = "Runs the integration tests"
group = "verification"
testClassesDirs = sourceSets["integrationTest"].output.classesDirs
classpath = sourceSets["integrationTest"].runtimeClasspath
outputs.upToDateWhen { false }
dependsOn("prepareConfluentArchive")
mustRunAfter("test")
systemProperties = System.getProperties() as Map<String, Any>
}
tasks.withType<Test> {
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
tasks.getByName("check").dependsOn(this)
systemProperty("file.encoding", "windows-1252") // run tests with different encoding
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
testLogging.exceptionFormat = TestExceptionFormat.FULL
val javaVersion: Int = (project.findProperty("javaVersion") as String? ?: defaultJdkVersion.toString()).toInt()
logger.info("Running tests using JDK$javaVersion")
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
})
systemProperties(mapOf("com.clickhouse.test.uri" to System.getProperty("com.clickhouse.test.uri", "")))
val jdkHome = project.findProperty("jdkHome") as String?
jdkHome.let {
val javaExecutablesPath = File(jdkHome, "bin/java")
if (javaExecutablesPath.exists()) {
executable = javaExecutablesPath.absolutePath
}
}
addTestListener(object : TestListener {
override fun beforeTest(testDescriptor: TestDescriptor?) {}
override fun beforeSuite(suite: TestDescriptor?) {}
override fun afterTest(testDescriptor: TestDescriptor?, result: TestResult?) {}
override fun afterSuite(d: TestDescriptor?, r: TestResult?) {
if (d != null && r != null && d.parent == null) {
val resultsSummary = """Tests summary:
| ${r.testCount} tests,
| ${r.successfulTestCount} succeeded,
| ${r.failedTestCount} failed,
| ${r.skippedTestCount} skipped""".trimMargin().replace("\n", "")
val border = "=".repeat(resultsSummary.length)
logger.lifecycle("\n$border")
logger.lifecycle("Test result: ${r.resultType}")
logger.lifecycle(resultsSummary)
logger.lifecycle("${border}\n")
}
}
})
}
/*
* ShadowJar
*/
tasks.withType<Jar> {
manifest {
attributes["Implementation-Title"] = "ClickHouse-Kafka-Connect"
attributes["Implementation-Version"] = project.version.toString()
}
}
tasks.register<ShadowJar>("confluentJar") {
archiveClassifier.set("confluent")
from(clickhouseDependencies, sourceSets.main.get().output)
}
/*
tasks.register<ShadowJar>("allJar") {
archiveClassifier.set("all")
from(clickhouseDependencies, sourceSets.main.get().output)
}
*/
// Confluent Archive
val releaseDate by extra(DateTimeFormatter.ISO_LOCAL_DATE.format(LocalDateTime.now()))
val archiveFilename = "clickhouse-kafka-connect"
tasks.register<Copy>("prepareConfluentArchive") {
group = "Confluent"
description = "Prepares the Confluent Archive ready for the hub"
dependsOn("confluentJar")
val baseDir = "$archiveFilename-${project.version}"
from("config/archive/manifest.json") {
expand(project.properties)
destinationDir = file("$buildDir/confluentArchive/$baseDir")
}
from("config/archive/assets") {
into("assets")
}
from("$buildDir/libs") {
include(listOf("${project.name}-${project.version}-confluent.jar"))
into("lib")
}
from(".") {
include(listOf("README.md", "LICENSE"))
into("doc")
}
}
tasks.register<Zip>("createConfluentArchive") {
group = "Confluent"
description = "Creates the Confluent Archive zipfile to be uploaded to the Confluent Hub"
dependsOn("prepareConfluentArchive")
from(files("$buildDir/confluentArchive"))
archiveBaseName.set("")
archiveAppendix.set(archiveFilename)
archiveVersion.set(project.version.toString())
destinationDirectory.set(file("$buildDir/confluent"))
}