Skip to content

Commit 1eeafb8

Browse files
committed
Added a Jar containing the Avro dependency as well
KAFKA-222
1 parent d227805 commit 1eeafb8

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

build.gradle.kts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,19 @@ extra.apply {
7171
set("connectUtilsVersion", "0.4+")
7272
}
7373

74+
val mongoDependencies: Configuration by configurations.creating
75+
val mongoAndAvroDependencies: Configuration by configurations.creating
76+
7477
dependencies {
7578
implementation("org.apache.kafka:connect-api:${project.extra["kafkaVersion"]}")
7679
implementation("org.mongodb:mongodb-driver-sync:${project.extra["mongodbDriverVersion"]}")
7780
implementation("org.apache.avro:avro:${project.extra["avroVersion"]}")
7881

82+
mongoDependencies("org.mongodb:mongodb-driver-sync:${project.extra["mongodbDriverVersion"]}")
83+
84+
mongoAndAvroDependencies("org.mongodb:mongodb-driver-sync:${project.extra["mongodbDriverVersion"]}")
85+
mongoAndAvroDependencies("org.apache.avro:avro:${project.extra["avroVersion"]}")
86+
7987
// Unit Tests
8088
testImplementation("org.junit.jupiter:junit-jupiter:${project.extra["junitJupiterVersion"]}")
8189
testImplementation("org.junit.platform:junit-platform-runner:${project.extra["junitPlatformVersion"]}")
@@ -232,14 +240,22 @@ tasks.named("compileJava") {
232240
/*
233241
* ShadowJar
234242
*/
235-
tasks.withType<ShadowJar> {
236-
dependencies {
237-
exclude({ !listOf("bson", "mongodb-driver-sync", "mongodb-driver-core").contains(it.getModuleName()) })
238-
}
243+
tasks.register<ShadowJar>("confluentJar") {
244+
archiveClassifier.set("confluent")
245+
from(mongoDependencies, sourceSets.main.get().output)
246+
}
247+
248+
tasks.register<ShadowJar>("allJar") {
249+
archiveClassifier.set("all")
250+
from(mongoAndAvroDependencies, sourceSets.main.get().output)
251+
}
239252

253+
tasks.withType<ShadowJar> {
254+
archiveAppendix.set("connect")
240255
doLast {
241256
val fatJar = archiveFile.get().asFile
242-
println("FatJar: ${fatJar.path} (${fatJar.length().toDouble() / (1_000 * 1_000)} MB)")
257+
val fatJarSize = "%.4f".format(fatJar.length().toDouble() / (1_000 * 1_000))
258+
println("FatJar: ${fatJar.path} ($fatJarSize MB)")
243259
}
244260
}
245261

@@ -378,7 +394,7 @@ val archiveFilename = "mongodb-kafka-connect-mongodb"
378394
tasks.register<Copy>("prepareConfluentArchive") {
379395
group = "Confluent"
380396
description = "Prepares the Confluent Archive ready for the hub"
381-
dependsOn("shadowJar")
397+
dependsOn("confluentJar")
382398

383399
val baseDir = "$archiveFilename-${project.version}"
384400
from("config/archive/manifest.json") {
@@ -396,7 +412,7 @@ tasks.register<Copy>("prepareConfluentArchive") {
396412
}
397413

398414
from("$buildDir/libs") {
399-
include(listOf("${project.name}-${project.version}-all.jar"))
415+
include(listOf("${project.name}-connect-${project.version}-confluent.jar"))
400416
into("lib")
401417
}
402418

0 commit comments

Comments
 (0)