Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions openai-java-client-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ plugins {
id("openai.publish")
}

listOf(configurations.testCompileClasspath, configurations.testRuntimeClasspath).forEach {
it.configure {
attributes.attribute(
org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE,
17,
)
}
}

configurations.testRuntimeClasspath.configure {
resolutionStrategy.eachDependency {
if (
requested.group == "com.fasterxml.jackson" ||
requested.group.startsWith("com.fasterxml.jackson.")
) {
useVersion("2.18.9")
because("tests must exercise the SDK's secure published Jackson release")
}
}
}

dependencies {
constraints {
testImplementation("com.google.guava:guava:33.6.0-jre") {
Expand Down Expand Up @@ -31,11 +52,11 @@ dependencies {

testImplementation(kotlin("test"))
testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation(platform("org.eclipse.jetty:jetty-bom:9.4.58.v20250814"))
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
testImplementation(platform("org.eclipse.jetty:jetty-bom:12.0.33"))
testImplementation(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.33"))
testImplementation("org.wiremock:wiremock-jetty12:3.13.2")

constraints {
// Keep handlebars-helpers at 4.3.1: WireMock 2 links helper classes moved in 4.5.x.
testImplementation("com.github.jknack:handlebars:4.5.3") {
because("WireMock's transitive 4.3.1 dependency is affected by CVE-2026-55760")
}
Expand Down
65 changes: 47 additions & 18 deletions openai-java-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,47 @@ plugins {
id("openai.publish")
}

listOf(configurations.testCompileClasspath, configurations.testRuntimeClasspath).forEach {
it.configure {
attributes.attribute(
org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE,
17,
)
}
}

val jacksonCompatibilityVersion = "2.14.0"
val jacksonPublishedVersion = "2.18.9"

// Runtime classpath for `testJacksonPublished`: the same dependencies as `testRuntimeClasspath`,
// but exempt from the compatibility-version force below so Jackson resolves to the version that
// consumers receive by default.
val jacksonPublishedRuntime by configurations.creating {
// Runtime classpath for `testJacksonCompatibility`: the same dependencies as
// `testRuntimeClasspath`, but forced to the older Jackson version that the SDK supports.
val jacksonCompatibilityRuntime by configurations.creating {
extendsFrom(configurations.testRuntimeClasspath.get())
isCanBeConsumed = false
isCanBeResolved = true
attributes.attribute(
org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE,
17,
)
}

// Keep the normal test runtime on the same secure Jackson release that consumers receive. WireMock
// 3 requires newer Jackson APIs, so compatibility testing runs separately below.
configurations.testRuntimeClasspath.configure {
resolutionStrategy.eachDependency {
if (
requested.group == "com.fasterxml.jackson" ||
requested.group.startsWith("com.fasterxml.jackson.")
) {
useVersion(jacksonPublishedVersion)
because("tests must exercise the SDK's secure published Jackson release")
}
}
}

// Palantir and Dokka are isolated build tools with independently aligned Jackson classpaths.
// Palantir, Dokka, and the normal test runtime have independently aligned Jackson classpaths.
configurations.matching {
it.name != jacksonPublishedRuntime.name &&
it.name != configurations.testRuntimeClasspath.get().name &&
it.name != "palantir" &&
!it.name.startsWith("dokka")
}.configureEach {
Expand Down Expand Up @@ -73,8 +99,9 @@ dependencies {

testImplementation(kotlin("test"))
testImplementation(project(":openai-java-client-okhttp"))
testImplementation(platform("org.eclipse.jetty:jetty-bom:9.4.58.v20250814"))
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
testImplementation(platform("org.eclipse.jetty:jetty-bom:12.0.33"))
testImplementation(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.33"))
testImplementation("org.wiremock:wiremock-jetty12:3.13.2")
testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3")
Expand All @@ -84,32 +111,34 @@ dependencies {
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")

constraints {
// Keep handlebars-helpers at 4.3.1: WireMock 2 links helper classes moved in 4.5.x.
testImplementation("com.github.jknack:handlebars:4.5.3") {
because("WireMock's transitive 4.3.1 dependency is affected by CVE-2026-55760")
}
}
}

// Re-run the compiled tests against the Jackson version consumers receive by default. Service tests
// exercise HTTP plumbing and the mock server rather than Jackson compatibility, so the second pass
// focuses on the core and model tests that cover serialization behavior.
val testJacksonPublished by tasks.registering(Test::class) {
// Re-run the core and model tests against the older supported Jackson version. Service and
// WireMock-specific tests exercise HTTP plumbing and the mock server rather than Jackson
// compatibility, and WireMock 3 requires newer Jackson APIs.
val testJacksonCompatibility by tasks.registering(Test::class) {
group = "verification"
description = "Runs tests against the published Jackson version."
description = "Runs core and model tests against the older supported Jackson version."
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().output + sourceSets.main.get().output + jacksonPublishedRuntime
classpath =
sourceSets.test.get().output + sourceSets.main.get().output + jacksonCompatibilityRuntime
shouldRunAfter(tasks.test)
exclude("**/services/**")
exclude("**/RetryingHttpClientTest*")
exclude("**/WireMockHandlebarsCompatibilityTest*")
systemProperty("junit.jupiter.execution.parallel.enabled", false)
systemProperty("expected.jackson.version", jacksonPublishedVersion)
systemProperty("expected.jackson.version", jacksonCompatibilityVersion)
}

tasks.test {
systemProperty("expected.jackson.version", jacksonCompatibilityVersion)
systemProperty("expected.jackson.version", jacksonPublishedVersion)
}

tasks.check { dependsOn(testJacksonPublished) }
tasks.check { dependsOn(testJacksonCompatibility) }

if (project.hasProperty("graalvmAgent")) {
java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.github.tomakehurst.wiremock.client.WireMock.aResponse
import com.github.tomakehurst.wiremock.client.WireMock.get
import com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo
import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig
import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer
import java.net.HttpURLConnection
import java.net.URL
import org.assertj.core.api.Assertions.assertThat
Expand All @@ -15,10 +14,7 @@ internal class WireMockHandlebarsCompatibilityTest {

@Test
fun rendersResponseTemplate() {
val server =
WireMockServer(
wireMockConfig().dynamicPort().extensions(ResponseTemplateTransformer(false))
)
val server = WireMockServer(wireMockConfig().dynamicPort())
server.start()

try {
Expand Down
Loading