@@ -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,21 +61,6 @@ 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
-
79
64
configure(coreProjects) {
80
65
apply plugin : ' idea'
81
66
@@ -97,11 +82,8 @@ configure(coreProjects) {
97
82
configure(javaProjects) {
98
83
apply plugin : ' java-library'
99
84
100
- java {
101
- toolchain {
102
- languageVersion = JavaLanguageVersion . of(DEFAULT_JDK_VERSION )
103
- }
104
- }
85
+ sourceCompatibility = JavaVersion . VERSION_1_8
86
+ targetCompatibility = JavaVersion . VERSION_1_8
105
87
106
88
sourceSets {
107
89
main {
@@ -112,7 +94,6 @@ configure(javaProjects) {
112
94
tasks. withType(GenerateModuleMetadata ) {
113
95
enabled = false
114
96
}
115
-
116
97
}
117
98
118
99
configure(scalaProjects) {
@@ -123,11 +104,8 @@ configure(scalaProjects) {
123
104
124
105
group = ' org.mongodb.scala'
125
106
126
- java {
127
- toolchain {
128
- languageVersion = JavaLanguageVersion . of(DEFAULT_JDK_VERSION )
129
- }
130
- }
107
+ sourceCompatibility = JavaVersion . VERSION_1_8
108
+ targetCompatibility = JavaVersion . VERSION_1_8
131
109
132
110
dependencies {
133
111
compile (' org.scala-lang:scala-library:%scala-version%' )
@@ -175,7 +153,7 @@ configure(scalaProjects) {
175
153
configure(javaMainProjects) {
176
154
apply plugin : ' nebula.optional-base'
177
155
apply plugin : ' java-library'
178
-
156
+
179
157
dependencies {
180
158
compileOnly ' com.google.code.findbugs:jsr305:1.3.9'
181
159
api ' org.slf4j:slf4j-api:1.7.6' , optional
@@ -352,6 +330,19 @@ configure(javaCodeCheckedProjects) {
352
330
spotbugsTest {
353
331
enabled = false
354
332
}
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
+ }
355
346
}
356
347
357
348
def getGitVersion () {
@@ -366,3 +357,15 @@ def getGitVersion() {
366
357
apply from : ' gradle/publish.gradle'
367
358
apply from : ' gradle/deploy.gradle'
368
359
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