Skip to content

Commit 7ebe71c

Browse files
committed
Revert "Build: Added java toolchain to build.gradle"
This reverts commit 1fe0761.
1 parent 7399618 commit 7ebe71c

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

build.gradle

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ buildscript {
2727
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
2828
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.0"
2929
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.1.2'
30-
30+
3131
// Scala plugins
3232
classpath "com.adtran:scala-multiversion-plugin:1.0.36"
3333
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.27.1"
@@ -61,21 +61,6 @@ def javaMainProjects = javaProjects.findAll { !['util'].contains(it.name) }
6161
def javaCodeCheckedProjects = javaMainProjects.findAll { !['driver-benchmarks', 'driver-workload-executor'].contains(it.name) }
6262
def javaAndScalaTestedProjects = javaCodeCheckedProjects + scalaProjects
6363

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-
7964
configure(coreProjects) {
8065
apply plugin: 'idea'
8166

@@ -97,11 +82,8 @@ configure(coreProjects) {
9782
configure(javaProjects) {
9883
apply plugin: 'java-library'
9984

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
10587

10688
sourceSets {
10789
main {
@@ -112,7 +94,6 @@ configure(javaProjects) {
11294
tasks.withType(GenerateModuleMetadata) {
11395
enabled = false
11496
}
115-
11697
}
11798

11899
configure(scalaProjects) {
@@ -123,11 +104,8 @@ configure(scalaProjects) {
123104

124105
group = 'org.mongodb.scala'
125106

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
131109

132110
dependencies {
133111
compile ('org.scala-lang:scala-library:%scala-version%')
@@ -175,7 +153,7 @@ configure(scalaProjects) {
175153
configure(javaMainProjects) {
176154
apply plugin: 'nebula.optional-base'
177155
apply plugin: 'java-library'
178-
156+
179157
dependencies {
180158
compileOnly 'com.google.code.findbugs:jsr305:1.3.9'
181159
api 'org.slf4j:slf4j-api:1.7.6', optional
@@ -352,6 +330,19 @@ configure(javaCodeCheckedProjects) {
352330
spotbugsTest {
353331
enabled = false
354332
}
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+
}
355346
}
356347

357348
def getGitVersion() {
@@ -366,3 +357,15 @@ def getGitVersion() {
366357
apply from: 'gradle/publish.gradle'
367358
apply from: 'gradle/deploy.gradle'
368359
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+
}

driver-core/src/main/com/mongodb/MongoCredential.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public static MongoCredential createPlainCredential(final String userName, final
293293
* {@code "JAVA_SUBJECT"} with the value of a {@code Subject} instance.
294294
* <p>
295295
* To override the properties of the {@link javax.security.sasl.SaslClient} with which the authentication executes, add a mechanism
296-
* property with the name {@code "JAVA_SASL_CLIENT_PROPERTIES"} with the value of a {@code Map<String, Object>} instance containing the
296+
* property with the name {@code "JAVA_SASL_CLIENT_PROPERTIES"} with the value of a {@code Map<String, Object} instance containing the
297297
* necessary properties. This can be useful if the application is customizing the default
298298
* {@link javax.security.sasl.SaslClientFactory}.
299299
*

0 commit comments

Comments
 (0)