diff --git a/Jenkinsfile b/Jenkinsfile index a4166365a..0d66f12e9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,14 +1,10 @@ @Library('shared-libraries') _ def getJava(){ - if(env.JAVA_VERSION=="JAVA17"){ - return "/home/builder/java/jdk-17.0.2" - }else if(env.JAVA_VERSION=="JAVA11"){ - return "/home/builder/java/jdk-11.0.2" - }else if(env.JAVA_VERSION=="JAVA21"){ + if (env.JAVA_VERSION == "JAVA21") { return "/home/builder/java/jdk-21.0.1" - }else{ - return "/home/builder/java/openjdk-1.8.0-262" + } else { + return "/home/builder/java/jdk-17.0.2" } } diff --git a/build.gradle b/build.gradle index d463947dd..359488d3c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,38 +4,38 @@ // used for that. So we have to add the properties plugin to the buildscript classpath and then apply the properties // plugin via subprojects below. buildscript { - repositories { - maven { - url = "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "net.saliman:gradle-properties-plugin:1.5.2" - } + repositories { + maven { + url = "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath "net.saliman:gradle-properties-plugin:1.5.2" + } } subprojects { - apply plugin: "net.saliman.properties" - apply plugin: 'java' + apply plugin: "net.saliman.properties" + apply plugin: 'java' - tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' - } + tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' + } - // To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8. - java { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - } + java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } + } - configurations { - testImplementation.extendsFrom compileOnly - } + configurations { + testImplementation.extendsFrom compileOnly + } - repositories { - mavenLocal() - mavenCentral() - } + repositories { + mavenLocal() + mavenCentral() + } test { systemProperty "file.encoding", "UTF-8" @@ -43,10 +43,10 @@ subprojects { } // Until we do a cleanup of javadoc errors, the build (and specifically the javadoc task) fails on Java 11 - // and higher. Preventing that until the cleanup can occur. - javadoc.failOnError = false + // and higher. Preventing that until the cleanup can occur. + javadoc.failOnError = false - // Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed. - // Until then, it's just a lot of noise. - javadoc.options.addStringOption('Xdoclint:none', '-quiet') + // Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed. + // Until then, it's just a lot of noise. + javadoc.options.addStringOption('Xdoclint:none', '-quiet') } diff --git a/marklogic-client-api-functionaltests/build.gradle b/marklogic-client-api-functionaltests/build.gradle index c12d6085f..489a1d077 100755 --- a/marklogic-client-api-functionaltests/build.gradle +++ b/marklogic-client-api-functionaltests/build.gradle @@ -19,7 +19,7 @@ dependencies { testImplementation 'org.skyscreamer:jsonassert:1.5.3' testImplementation 'org.slf4j:slf4j-api:2.0.17' testImplementation 'commons-io:commons-io:2.17.0' - testImplementation 'com.squareup.okhttp3:okhttp:4.12.0' + testImplementation 'com.squareup.okhttp3:okhttp:5.1.0' testImplementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}" testImplementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" testImplementation "org.jdom:jdom2:2.0.6.1" @@ -32,7 +32,7 @@ dependencies { exclude module: "commons-lang3" } - testImplementation 'ch.qos.logback:logback-classic:1.3.15' + testImplementation 'ch.qos.logback:logback-classic:1.5.18' testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation 'org.xmlunit:xmlunit-legacy:2.10.0' diff --git a/marklogic-client-api/build.gradle b/marklogic-client-api/build.gradle index b2bfdd46d..7bb2b8ffe 100644 --- a/marklogic-client-api/build.gradle +++ b/marklogic-client-api/build.gradle @@ -18,9 +18,9 @@ dependencies { api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1" implementation "org.glassfish.jaxb:jaxb-runtime:3.0.2" - implementation 'com.squareup.okhttp3:okhttp:4.12.0' - implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' - implementation 'io.github.rburgst:okhttp-digest:2.7' + implementation 'com.squareup.okhttp3:okhttp:5.1.0' + implementation 'com.squareup.okhttp3:logging-interceptor:5.1.0' + implementation 'io.github.rburgst:okhttp-digest:3.1.1' // We tried upgrading to the org.eclipse.angus:angus-mail dependency, but we ran into significant performance issues // with using the Java Client eval call in our Spark connector. Example - an eval() call for getting 50k URIs would @@ -57,10 +57,10 @@ dependencies { // Starting with mockito 5.x, Java 11 is required, so sticking with 4.x as we have to support Java 8. testImplementation "org.mockito:mockito-core:4.11.0" testImplementation "org.mockito:mockito-inline:4.11.0" - testImplementation "com.squareup.okhttp3:mockwebserver:4.12.0" + testImplementation "com.squareup.okhttp3:mockwebserver3:5.1.0" testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jacksonVersion}" - testImplementation 'ch.qos.logback:logback-classic:1.3.15' + testImplementation 'ch.qos.logback:logback-classic:1.5.18' // Using this to avoid a schema validation issue with the regular xercesImpl testImplementation 'org.opengis.cite.xerces:xercesImpl-xsd11:2.12-beta-r1667115' diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/OAuthAuthenticationConfigurerTest.java b/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/OAuthAuthenticationConfigurerTest.java index b6bee7c30..70e2e520f 100644 --- a/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/OAuthAuthenticationConfigurerTest.java +++ b/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/OAuthAuthenticationConfigurerTest.java @@ -4,19 +4,21 @@ package com.marklogic.client.impl.okhttp; import com.marklogic.client.DatabaseClientFactory; +import mockwebserver3.MockWebServer; import okhttp3.Request; -import okhttp3.mockwebserver.MockWebServer; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -public class OAuthAuthenticationConfigurerTest { +class OAuthAuthenticationConfigurerTest { @Test - void test() { - DatabaseClientFactory.OAuthContext authContext = new DatabaseClientFactory.OAuthContext("abc123"); - Request request = new Request.Builder().url(new MockWebServer().url("/url-doesnt-matter")).build(); + void test() throws Exception { + MockWebServer mockWebServer = new MockWebServer(); + mockWebServer.start(); + Request request = new Request.Builder().url(mockWebServer.url("/url-doesnt-matter")).build(); + DatabaseClientFactory.OAuthContext authContext = new DatabaseClientFactory.OAuthContext("abc123"); Request authenticatedRequest = new OAuthAuthenticationConfigurer().makeAuthenticatedRequest(request, authContext); assertEquals("Bearer abc123", authenticatedRequest.header("Authorization")); } diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/TokenAuthenticationInterceptorTest.java b/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/TokenAuthenticationInterceptorTest.java index 2f1496497..0cc91aaab 100644 --- a/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/TokenAuthenticationInterceptorTest.java +++ b/marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/TokenAuthenticationInterceptorTest.java @@ -4,10 +4,10 @@ package com.marklogic.client.impl.okhttp; import com.marklogic.client.ext.helper.LoggingObject; +import mockwebserver3.MockResponse; +import mockwebserver3.MockWebServer; import okhttp3.OkHttpClient; import okhttp3.Request; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -23,7 +23,7 @@ * Uses OkHttp's MockWebServer to completely mock a MarkLogic instance so that we can control what response codes are * returned and processed by TokenAuthenticationInterceptor. */ -public class TokenAuthenticationInterceptorTest extends LoggingObject { +class TokenAuthenticationInterceptorTest extends LoggingObject { private MockWebServer mockWebServer; private FakeTokenGenerator fakeTokenGenerator; @@ -110,7 +110,12 @@ void multipleThreads() throws Exception { */ private void enqueueResponseCodes(int... codes) { for (int code : codes) { - mockWebServer.enqueue(new MockResponse().setResponseCode(code)); + mockWebServer.enqueue(new MockResponse.Builder().code(code).build()); + } + try { + mockWebServer.start(); + } catch (IOException e) { + throw new RuntimeException(e); } } diff --git a/ml-development-tools/build.gradle b/ml-development-tools/build.gradle index 2308b5c70..2d61adf0e 100644 --- a/ml-development-tools/build.gradle +++ b/ml-development-tools/build.gradle @@ -71,10 +71,10 @@ publishing { } compileKotlin { - kotlinOptions.jvmTarget = '1.8' + kotlinOptions.jvmTarget = '17' } compileTestKotlin { - kotlinOptions.jvmTarget = '1.8' + kotlinOptions.jvmTarget = '17' } tasks.register("generateTests", JavaExec) { diff --git a/settings.gradle b/settings.gradle index ab9b8f2d5..0526ec39f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,9 @@ +plugins { + // Allows for downloading a JDK based on Gradle toolchain configuration. + // Using a version prior to 1.0, which requires Java 17, and Jenkins is using Java 8. + id "org.gradle.toolchains.foojay-resolver-convention" version "0.10.0" +} + rootProject.name = 'marklogic-client-api-parent' include ':marklogic-client-api' include ':marklogic-client-api-functionaltests'