Skip to content

Commit

Permalink
Revert "Build: Added java toolchain to build.gradle"
Browse files Browse the repository at this point in the history
This reverts commit 1fe0761.
  • Loading branch information
jyemin committed Nov 11, 2021
1 parent 7399618 commit 7ebe71c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
59 changes: 31 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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'

Expand All @@ -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 {
Expand All @@ -112,7 +94,6 @@ configure(javaProjects) {
tasks.withType(GenerateModuleMetadata) {
enabled = false
}

}

configure(scalaProjects) {
Expand All @@ -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%')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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()
)
}
2 changes: 1 addition & 1 deletion driver-core/src/main/com/mongodb/MongoCredential.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public static MongoCredential createPlainCredential(final String userName, final
* {@code "JAVA_SUBJECT"} with the value of a {@code Subject} instance.
* <p>
* 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<String, Object>} instance containing the
* property with the name {@code "JAVA_SASL_CLIENT_PROPERTIES"} with the value of a {@code Map<String, Object} instance containing the
* necessary properties. This can be useful if the application is customizing the default
* {@link javax.security.sasl.SaslClientFactory}.
*
Expand Down

0 comments on commit 7ebe71c

Please sign in to comment.