From 7ebe71c2cf0a8f786b0fd79ddafbedc06a489ebb Mon Sep 17 00:00:00 2001 From: Jeff Yemin Date: Thu, 11 Nov 2021 12:01:14 -0500 Subject: [PATCH] Revert "Build: Added java toolchain to build.gradle" This reverts commit 1fe07610a34d2e4a2e533698bbbdb8a08f801c9f. --- build.gradle | 59 ++++++++++--------- .../src/main/com/mongodb/MongoCredential.java | 2 +- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index d4bb39c8fbd..bdfd1f5e2c9 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ buildscript { classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3' classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.0" classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.1.2' - + // Scala plugins classpath "com.adtran:scala-multiversion-plugin:1.0.36" classpath "com.diffplug.spotless:spotless-plugin-gradle:3.27.1" @@ -61,21 +61,6 @@ def javaMainProjects = javaProjects.findAll { !['util'].contains(it.name) } def javaCodeCheckedProjects = javaMainProjects.findAll { !['driver-benchmarks', 'driver-workload-executor'].contains(it.name) } def javaAndScalaTestedProjects = javaCodeCheckedProjects + scalaProjects -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.release.set(8) -} - -final Integer DEFAULT_JDK_VERSION = 11 - -tasks.withType(Test) { - def javaVersion = (findProperty("jdkVersion") ?: DEFAULT_JDK_VERSION.toString()).toInteger() - logger.info("Running tests using JDK$javaVersion") - javaLauncher.set(javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(javaVersion) - }) -} - configure(coreProjects) { apply plugin: 'idea' @@ -97,11 +82,8 @@ configure(coreProjects) { configure(javaProjects) { apply plugin: 'java-library' - java { - toolchain { - languageVersion = JavaLanguageVersion.of(DEFAULT_JDK_VERSION) - } - } + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 sourceSets { main { @@ -112,7 +94,6 @@ configure(javaProjects) { tasks.withType(GenerateModuleMetadata) { enabled = false } - } configure(scalaProjects) { @@ -123,11 +104,8 @@ configure(scalaProjects) { group = 'org.mongodb.scala' - java { - toolchain { - languageVersion = JavaLanguageVersion.of(DEFAULT_JDK_VERSION) - } - } + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 dependencies { compile ('org.scala-lang:scala-library:%scala-version%') @@ -175,7 +153,7 @@ configure(scalaProjects) { configure(javaMainProjects) { apply plugin: 'nebula.optional-base' apply plugin: 'java-library' - + dependencies { compileOnly 'com.google.code.findbugs:jsr305:1.3.9' api 'org.slf4j:slf4j-api:1.7.6', optional @@ -352,6 +330,19 @@ configure(javaCodeCheckedProjects) { spotbugsTest { enabled = false } + + tasks.withType(Test) { + def jdkHome = findProperty("jdkHome") + if (jdkHome) { + def javaExecutablesPath = new File(jdkHome, 'bin') + def javaExecutables = [:].withDefault { execName -> + def executable = new File(javaExecutablesPath, execName) + assert executable.exists() : "There is no ${execName} executable in ${javaExecutablesPath}" + executable + } + executable = javaExecutables.java + } + } } def getGitVersion() { @@ -366,3 +357,15 @@ def getGitVersion() { apply from: 'gradle/publish.gradle' apply from: 'gradle/deploy.gradle' apply from: 'gradle/javadoc.gradle' + +////////////////////////////////////////// +// Root project configuration // +////////////////////////////////////////// + +if (!JavaVersion.current().isJava9Compatible()) { + throw new GradleException(""" + | ERROR: + | JDK ${JavaVersion.VERSION_1_9.getMajorVersion()} is required to build the driver: You are using JDK ${JavaVersion.current().getMajorVersion()}. + |""".stripMargin() + ) +} diff --git a/driver-core/src/main/com/mongodb/MongoCredential.java b/driver-core/src/main/com/mongodb/MongoCredential.java index 95156dbe48e..1af4efc4590 100644 --- a/driver-core/src/main/com/mongodb/MongoCredential.java +++ b/driver-core/src/main/com/mongodb/MongoCredential.java @@ -293,7 +293,7 @@ public static MongoCredential createPlainCredential(final String userName, final * {@code "JAVA_SUBJECT"} with the value of a {@code Subject} instance. *

* To override the properties of the {@link javax.security.sasl.SaslClient} with which the authentication executes, add a mechanism - * property with the name {@code "JAVA_SASL_CLIENT_PROPERTIES"} with the value of a {@code Map} instance containing the + * property with the name {@code "JAVA_SASL_CLIENT_PROPERTIES"} with the value of a {@code Map