@@ -27,7 +27,7 @@ buildscript {
27
27
classpath ' com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
28
28
classpath " gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.0"
29
29
classpath ' biz.aQute.bnd:biz.aQute.bnd.gradle:5.1.2'
30
-
30
+
31
31
// Scala plugins
32
32
classpath " com.adtran:scala-multiversion-plugin:1.0.36"
33
33
classpath " com.diffplug.spotless:spotless-plugin-gradle:3.27.1"
@@ -61,6 +61,21 @@ def javaMainProjects = javaProjects.findAll { !['util'].contains(it.name) }
61
61
def javaCodeCheckedProjects = javaMainProjects. findAll { ! [' driver-benchmarks' , ' driver-workload-executor' ]. contains(it. name) }
62
62
def javaAndScalaTestedProjects = javaCodeCheckedProjects + scalaProjects
63
63
64
+ tasks. withType(JavaCompile ) {
65
+ options. encoding = " UTF-8"
66
+ options. release. set(8 )
67
+ }
68
+
69
+ final Integer DEFAULT_JDK_VERSION = 11
70
+
71
+ tasks. withType(Test ) {
72
+ def javaVersion = (findProperty(" jdkVersion" ) ?: DEFAULT_JDK_VERSION . toString()). toInteger()
73
+ logger. info(" Running tests using JDK$javaVersion " )
74
+ javaLauncher. set(javaToolchains. launcherFor {
75
+ languageVersion = JavaLanguageVersion . of(javaVersion)
76
+ })
77
+ }
78
+
64
79
configure(coreProjects) {
65
80
apply plugin : ' idea'
66
81
@@ -82,8 +97,11 @@ configure(coreProjects) {
82
97
configure(javaProjects) {
83
98
apply plugin : ' java-library'
84
99
85
- sourceCompatibility = JavaVersion . VERSION_1_8
86
- targetCompatibility = JavaVersion . VERSION_1_8
100
+ java {
101
+ toolchain {
102
+ languageVersion = JavaLanguageVersion . of(DEFAULT_JDK_VERSION )
103
+ }
104
+ }
87
105
88
106
sourceSets {
89
107
main {
@@ -94,6 +112,7 @@ configure(javaProjects) {
94
112
tasks. withType(GenerateModuleMetadata ) {
95
113
enabled = false
96
114
}
115
+
97
116
}
98
117
99
118
configure(scalaProjects) {
@@ -104,8 +123,11 @@ configure(scalaProjects) {
104
123
105
124
group = ' org.mongodb.scala'
106
125
107
- sourceCompatibility = JavaVersion . VERSION_1_8
108
- targetCompatibility = JavaVersion . VERSION_1_8
126
+ java {
127
+ toolchain {
128
+ languageVersion = JavaLanguageVersion . of(DEFAULT_JDK_VERSION )
129
+ }
130
+ }
109
131
110
132
dependencies {
111
133
compile (' org.scala-lang:scala-library:%scala-version%' )
@@ -153,7 +175,7 @@ configure(scalaProjects) {
153
175
configure(javaMainProjects) {
154
176
apply plugin : ' nebula.optional-base'
155
177
apply plugin : ' java-library'
156
-
178
+
157
179
dependencies {
158
180
compileOnly ' com.google.code.findbugs:jsr305:1.3.9'
159
181
api ' org.slf4j:slf4j-api:1.7.6' , optional
@@ -330,19 +352,6 @@ configure(javaCodeCheckedProjects) {
330
352
spotbugsTest {
331
353
enabled = false
332
354
}
333
-
334
- tasks. withType(Test ) {
335
- def jdkHome = findProperty(" jdkHome" )
336
- if (jdkHome) {
337
- def javaExecutablesPath = new File (jdkHome, ' bin' )
338
- def javaExecutables = [:]. withDefault { execName ->
339
- def executable = new File (javaExecutablesPath, execName)
340
- assert executable. exists() : " There is no ${ execName} executable in ${ javaExecutablesPath} "
341
- executable
342
- }
343
- executable = javaExecutables. java
344
- }
345
- }
346
355
}
347
356
348
357
def getGitVersion () {
@@ -357,15 +366,3 @@ def getGitVersion() {
357
366
apply from : ' gradle/publish.gradle'
358
367
apply from : ' gradle/deploy.gradle'
359
368
apply from : ' gradle/javadoc.gradle'
360
-
361
- // ////////////////////////////////////////
362
- // Root project configuration //
363
- // ////////////////////////////////////////
364
-
365
- if (! JavaVersion . current(). isJava9Compatible()) {
366
- throw new GradleException ("""
367
- | ERROR:
368
- | JDK ${ JavaVersion.VERSION_1_9.getMajorVersion()} is required to build the driver: You are using JDK ${ JavaVersion.current().getMajorVersion()} .
369
- |""" . stripMargin()
370
- )
371
- }
0 commit comments