forked from ClickHouse/clickhouse-kafka-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
227 lines (195 loc) · 8.88 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
/*
* 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 org.gradle.api.tasks.testing.logging.TestExceptionFormat
val defaultJdkVersion = 17
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
buildscript {
repositories {
mavenCentral()
maven{ url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
}
}
plugins {
idea
`java-library`
`maven-publish`
signing
// checkstyle
id("com.github.gmazzo.buildconfig") version "5.5.0"
id("com.diffplug.spotless") version "6.25.0"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("co.uzzu.dotenv.gradle") version "4.0.0" apply true
}
group = "com.airthings.clickhouse"
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.7.1")
set("kafkaVersion", "2.7.0")
// 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("com.clickhouse:client-v2:${project.extra["clickHouseDriverVersion"]}")
implementation("io.projectreactor:reactor-core:3.7.0")
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.3.1-jre")
// Avoid telescoping constructors problem with the builder pattern using Lombok
compileOnly("org.projectlombok:lombok:1.18.34")
annotationProcessor("org.projectlombok:lombok:1.18.34")
// To parse JSON response from ClickHouse to parse complex data types correctly
implementation("com.fasterxml.jackson.core:jackson-core:2.17.2")
implementation("com.fasterxml.jackson.core:jackson-databind:2.17.2")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1")
// TODO: need to remove ???
implementation("org.slf4j:slf4j-reload4j:2.0.13")
implementation("org.junit.jupiter:junit-jupiter-api:5.11.3")
implementation("org.testcontainers:testcontainers:1.20.1")
implementation("org.testcontainers:toxiproxy:1.20.1")
/*
Will in side the Confluent Archive
*/
clickhouseDependencies("org.apache.httpcomponents.client5:httpclient5:5.3.1")
clickhouseDependencies("io.lettuce:lettuce-core:6.5.0.RELEASE")
clickhouseDependencies("com.clickhouse:clickhouse-client:${project.extra["clickHouseDriverVersion"]}")
clickhouseDependencies("com.clickhouse:client-v2:${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.2")
clickhouseDependencies("com.fasterxml.jackson.core:jackson-databind:2.17.2")
clickhouseDependencies("com.fasterxml.jackson.core:jackson-annotations:2.18.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.20.3")
testImplementation("org.testcontainers:kafka:1.20.1")
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation("org.json:json:20240303")
testImplementation("org.testcontainers:toxiproxy:1.20.1")
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:client-v2:${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<JavaCompile> {
options.compilerArgs.addAll(listOf("-Xlint:unchecked", "-Xlint:deprecation"))
}
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()
}
}
publishing {
repositories {
maven {
name = "AirthingsGitHubPackages"
url = uri("https://maven.pkg.github.com/airthings/clickhouse-kafka-connect")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
register<MavenPublication>("gpr") {
from(components["java"])
}
}
}