@@ -32,24 +32,19 @@ plugins {
3232 `maven- publish`
3333 signing
3434 checkstyle
35- id(" de.fuerstenau. buildconfig" ) version " 1.1.8 "
36- id(" com.github.spotbugs" ) version " 4.6.0 "
37- id(" com.diffplug.spotless" ) version " 5.10.0 "
35+ id(" com.github.gmazzo. buildconfig" ) version " 3.0.3 "
36+ id(" com.github.spotbugs" ) version " 4.7.9 "
37+ id(" com.diffplug.spotless" ) version " 5.17.1 "
3838 id(" com.github.johnrengelman.shadow" ) version " 6.1.0"
3939}
4040
4141group = " org.mongodb.kafka"
4242version = " 1.7.0-SNAPSHOT"
4343description = " The official MongoDB Apache Kafka Connect Connector."
4444
45- java {
46- sourceCompatibility = JavaVersion .VERSION_1_8
47- targetCompatibility = JavaVersion .VERSION_1_8
48- }
49-
5045repositories {
5146 mavenCentral()
52- maven(" http ://packages.confluent.io/maven/" )
47+ maven(" https ://packages.confluent.io/maven/" )
5348 maven(" https://jitpack.io" )
5449}
5550
@@ -59,10 +54,10 @@ extra.apply {
5954 set(" avroVersion" , " 1.9.2" )
6055
6156 // Testing dependencies
62- set(" junitJupiterVersion" , " 5.4.0 " )
63- set(" junitPlatformVersion" , " 1.4.0 " )
64- set(" hamcrestVersion" , " 2.0.0.0 " )
65- set(" mockitoVersion" , " 2.27 .0" )
57+ set(" junitJupiterVersion" , " 5.8.1 " )
58+ set(" junitPlatformVersion" , " 1.8.1 " )
59+ set(" hamcrestVersion" , " 2.2 " )
60+ set(" mockitoVersion" , " 4.0 .0" )
6661
6762 // Integration test dependencies
6863 set(" confluentVersion" , " 6.0.1" )
@@ -85,9 +80,11 @@ dependencies {
8580 mongoAndAvroDependencies(" org.apache.avro:avro:${project.extra[" avroVersion" ]} " )
8681
8782 // Unit Tests
88- testImplementation(" org.junit.jupiter:junit-jupiter:${project.extra[" junitJupiterVersion" ]} " )
89- testImplementation(" org.junit.platform:junit-platform-runner:${project.extra[" junitPlatformVersion" ]} " )
90- testImplementation(" org.hamcrest:hamcrest-junit:${project.extra[" hamcrestVersion" ]} " )
83+ testImplementation(platform(" org.junit:junit-bom:${project.extra[" junitJupiterVersion" ]} " ))
84+ testImplementation(" org.junit.jupiter:junit-jupiter" )
85+ testImplementation(" org.junit.platform:junit-platform-runner" )
86+ testImplementation(" org.apiguardian:apiguardian-api:1.1.2" ) // https://github.com/gradle/gradle/issues/18627
87+ testImplementation(" org.hamcrest:hamcrest:${project.extra[" hamcrestVersion" ]} " )
9188 testImplementation(" org.mockito:mockito-junit-jupiter:${project.extra[" mockitoVersion" ]} " )
9289
9390 // Integration Tests
@@ -108,6 +105,14 @@ dependencies {
108105
109106tasks.withType<JavaCompile > {
110107 options.encoding = " UTF-8"
108+ options.release.set(8 )
109+ }
110+
111+ val defaultJdkVersion = 17
112+ java {
113+ toolchain {
114+ languageVersion.set(JavaLanguageVersion .of(defaultJdkVersion))
115+ }
111116}
112117
113118/*
@@ -123,18 +128,19 @@ val gitVersion: String by lazy {
123128}
124129
125130buildConfig {
126- appName = " mongo-kafka"
127- version = gitVersion
128- clsName = " Versions"
129- packageName = " com.mongodb.kafka.connect"
131+ className(" Versions" )
132+ packageName(" com.mongodb.kafka.connect" )
133+ useJavaOutput()
134+ buildConfigField(" String" , " NAME" , " \" mongo-kafka\" " )
135+ buildConfigField(" String" , " VERSION" , provider { " \" ${gitVersion} \" " })
130136}
131137
132138/*
133139 * Testing
134140 */
141+
135142sourceSets.create(" integrationTest" ) {
136143 java.srcDir(" src/integrationTest/java" )
137- resources.srcDir(" src/integrationTest/resources" )
138144 compileClasspath + = sourceSets[" main" ].output + configurations[" testRuntimeClasspath" ]
139145 runtimeClasspath + = output + compileClasspath + sourceSets[" test" ].runtimeClasspath
140146}
@@ -155,6 +161,12 @@ tasks.withType<Test> {
155161 events(" passed" , " skipped" , " failed" )
156162 }
157163
164+ val javaVersion: Int = (project.findProperty(" javaVersion" ) as String? ? : defaultJdkVersion.toString()).toInt()
165+ logger.info(" Running tests using JDK$javaVersion " )
166+ javaLauncher.set(javaToolchains.launcherFor {
167+ languageVersion.set(JavaLanguageVersion .of(javaVersion))
168+ })
169+
158170 systemProperties(mapOf (" org.mongodb.test.uri" to System .getProperty(" org.mongodb.test.uri" , " " )))
159171
160172 val jdkHome = project.findProperty(" jdkHome" ) as String?
@@ -210,7 +222,7 @@ tasks.withType<com.github.spotbugs.snom.SpotBugsTask> {
210222// Spotless is used to lint and reformat source files.
211223spotless {
212224 java {
213- googleJavaFormat()
225+ googleJavaFormat(" 1.12.0 " )
214226 importOrder(" java" , " io" , " org" , " org.bson" , " com.mongodb" , " com.mongodb.kafka" , " " )
215227 removeUnusedImports() // removes any unused imports
216228 trimTrailingWhitespace()
0 commit comments