1+ /*
2+ * This file is the build file of flink-connector-clickhouse-base submodule
3+ *
4+ */
5+
6+ plugins {
7+ `maven- publish`
8+ scala
9+ java
10+ signing
11+ id(" com.gradleup.nmcp" ) version " 0.0.8"
12+ id(" com.github.johnrengelman.shadow" ) version " 8.1.1"
13+ }
14+
15+ val scalaVersion = " 2.13.12"
16+ val sinkVersion: String by rootProject.extra
17+
18+ repositories {
19+ // Use Maven Central for resolving dependencies.
20+ // mavenLocal()
21+ maven(" https://s01.oss.sonatype.org/content/groups/staging/" ) // Temporary until we have a Java Client release
22+ mavenCentral()
23+ }
24+
25+ val flinkVersion = System .getenv(" FLINK_VERSION" ) ? : " 1.17.2"
26+
27+ extra.apply {
28+ set(" clickHouseDriverVersion" , " 0.9.0-SNAPSHOT" ) // Temporary until we have a Java Client release
29+ set(" flinkVersion" , flinkVersion)
30+ set(" log4jVersion" ," 2.17.2" )
31+ set(" testContainersVersion" , " 1.21.0" )
32+ set(" byteBuddyVersion" , " 1.17.5" )
33+ }
34+
35+ dependencies {
36+ // Use JUnit Jupiter for testing.
37+ testImplementation(libs.junit.jupiter)
38+
39+ testRuntimeOnly(" org.junit.platform:junit-platform-launcher" )
40+
41+ implementation(" net.bytebuddy:byte-buddy:${project.extra[" byteBuddyVersion" ]} " )
42+ implementation(" net.bytebuddy:byte-buddy-agent:${project.extra[" byteBuddyVersion" ]} " )
43+ // This dependency is used by the application.
44+ implementation(libs.guava)
45+ implementation(" org.scala-lang:scala-library:$scalaVersion " )
46+ implementation(" org.scala-lang:scala-compiler:$scalaVersion " )
47+ // logger
48+ implementation(" org.apache.logging.log4j:log4j-slf4j-impl:${project.extra[" log4jVersion" ]} " )
49+ implementation(" org.apache.logging.log4j:log4j-api:${project.extra[" log4jVersion" ]} " )
50+ implementation(" org.apache.logging.log4j:log4j-1.2-api:${project.extra[" log4jVersion" ]} " )
51+ implementation(" org.apache.logging.log4j:log4j-core:${project.extra[" log4jVersion" ]} " )
52+
53+ // ClickHouse Client Libraries
54+ implementation(" com.clickhouse:client-v2:${project.extra[" clickHouseDriverVersion" ]} :all" )
55+ // Apache Flink Libraries
56+ implementation(" org.apache.flink:flink-connector-base:${project.extra[" flinkVersion" ]} " )
57+ implementation(" org.apache.flink:flink-streaming-java:${project.extra[" flinkVersion" ]} " )
58+
59+
60+ testImplementation(" org.apache.flink:flink-connector-files:${project.extra[" flinkVersion" ]} " )
61+ testImplementation(" org.apache.flink:flink-connector-base:${project.extra[" flinkVersion" ]} " )
62+ testImplementation(" org.apache.flink:flink-streaming-java:${project.extra[" flinkVersion" ]} " )
63+ testImplementation(" org.apache.flink:flink-clients:${project.extra[" flinkVersion" ]} " )
64+ testImplementation(" org.apache.flink:flink-runtime:${project.extra[" flinkVersion" ]} " )
65+ // logger
66+ testImplementation(" org.apache.logging.log4j:log4j-slf4j-impl:${project.extra[" log4jVersion" ]} " )
67+ testImplementation(" org.apache.logging.log4j:log4j-api:${project.extra[" log4jVersion" ]} " )
68+ testImplementation(" org.apache.logging.log4j:log4j-1.2-api:${project.extra[" log4jVersion" ]} " )
69+ testImplementation(" org.apache.logging.log4j:log4j-core:${project.extra[" log4jVersion" ]} " )
70+ // flink tests
71+ testImplementation(" org.apache.flink:flink-test-utils:${project.extra[" flinkVersion" ]} " )
72+ //
73+ testImplementation(" org.testcontainers:testcontainers:${project.extra[" testContainersVersion" ]} " )
74+ testImplementation(" org.testcontainers:clickhouse:${project.extra[" testContainersVersion" ]} " )
75+ testImplementation(" org.scalatest:scalatest_2.13:3.2.19" )
76+ testRuntimeOnly(" org.scalatestplus:junit-4-13_2.13:3.2.18.0" )
77+ // testRuntimeOnly("org.pegdown:pegdown:1.6.0") // sometimes required by ScalaTest
78+ }
79+
80+ sourceSets {
81+ main {
82+ scala {
83+ srcDirs(" src/main/scala" )
84+ }
85+ java {
86+ srcDirs(" src/main/java" )
87+ }
88+ }
89+ test {
90+ scala {
91+ srcDirs(" src/test/scala" )
92+ }
93+ java {
94+ srcDirs(" src/test/java" )
95+ }
96+ }
97+ }
98+
99+ // Apply a specific Java toolchain to ease working on different environments.
100+ java {
101+ toolchain {
102+ languageVersion = JavaLanguageVersion .of(11 )
103+ }
104+ }
105+
106+ tasks.test {
107+ useJUnitPlatform()
108+
109+ include(" **/*Test.class" , " **/*Tests.class" , " **/*Spec.class" )
110+ testLogging {
111+ events(" passed" , " failed" , " skipped" )
112+ // showStandardStreams = true - , "standardOut", "standardError"
113+ }
114+ }
115+
116+ tasks.withType<ScalaCompile > {
117+ scalaCompileOptions.apply {
118+ encoding = " UTF-8"
119+ isDeprecation = true
120+ additionalParameters = listOf (" -feature" , " -unchecked" )
121+ }
122+ }
123+
124+ tasks.named<Test >(" test" ) {
125+ // Use JUnit Platform for unit tests.
126+ useJUnitPlatform()
127+ }
128+
129+ tasks.register<JavaExec >(" runScalaTests" ) {
130+ group = " verification"
131+ mainClass.set(" org.scalatest.tools.Runner" )
132+ classpath = sourceSets[" test" ].runtimeClasspath
133+ args = listOf (
134+ " -R" , " build/classes/scala/test" ,
135+ " -oD" , // show durations
136+ " -s" , " org.apache.flink.connector.clickhouse.test.scala.ClickHouseSinkTests"
137+ )
138+ }
139+
140+ tasks.shadowJar {
141+ archiveClassifier.set(" all" )
142+
143+ dependencies {
144+ exclude(dependency(" org.apache.flink:.*" ))
145+ }
146+ mergeServiceFiles()
147+ }
148+
149+ val shadowSourcesJar by tasks.registering(Jar ::class ) {
150+ archiveClassifier.set(" all-sources" )
151+ from(sourceSets.main.get().allSource)
152+ duplicatesStrategy = DuplicatesStrategy .EXCLUDE
153+ }
154+
155+ tasks.jar {
156+ enabled = false
157+ }
158+
159+ publishing {
160+ publications {
161+ create<MavenPublication >(" maven" ) {
162+ artifact(tasks.shadowJar)
163+ groupId = " com.clickhouse.flink"
164+ artifactId = " flink-connector-clickhouse"
165+ version = sinkVersion
166+
167+ artifact(shadowSourcesJar)
168+
169+ pom {
170+ name.set(" ClickHouse Flink Connector" )
171+ description.set(" Official Apache Flink connector for ClickHouse" )
172+ url.set(" https://github.com/ClickHouse/flink-connector-clickhouse" )
173+
174+ licenses {
175+ license {
176+ name.set(" The Apache License, Version 2.0" )
177+ url.set(" https://github.com/ClickHouse/flink-connector-clickhouse/blob/main/LICENSE" )
178+ }
179+ }
180+
181+ developers {
182+ developer {
183+ id.set(" mzitnik" )
184+ name.set(" Mark Zitnik" )
185+ 186+ }
187+ developer {
188+ id.set(" BentsiLeviav" )
189+ name.set(" Bentsi Leviav" )
190+ 191+ }
192+ }
193+
194+ scm {
195+ connection.set(
" [email protected] :ClickHouse/flink-connector-clickhouse.git" )
196+ url.set(" https://github.com/ClickHouse/flink-connector-clickhouse" )
197+ }
198+
199+ organization {
200+ name.set(" ClickHouse" )
201+ url.set(" https://clickhouse.com" )
202+ }
203+
204+ issueManagement {
205+ system.set(" GitHub Issues" )
206+ url.set(" https://github.com/ClickHouse/flink-connector-clickhouse/issues" )
207+ }
208+ }
209+ }
210+ }
211+ }
212+
213+ signing {
214+ val signingKey = System .getenv(" SIGNING_KEY" )
215+ val signingPassword = System .getenv(" SIGNING_PASSWORD" )
216+ if (signingKey != null && signingPassword != null ) {
217+ useInMemoryPgpKeys(signingKey, signingPassword)
218+ sign(publishing.publications[" maven" ])
219+ }
220+ }
221+
222+ nmcp {
223+ publish(" maven" ) {
224+ username = System .getenv(" NMCP_USERNAME" )
225+ password = System .getenv(" NMCP_PASSWORD" )
226+ publicationType = " AUTOMATIC"
227+ }
228+ }
0 commit comments