From e2a9113720e4d2b0cd75acf0db3a0b745926fdd8 Mon Sep 17 00:00:00 2001 From: Hugo Costa Date: Sat, 30 Aug 2025 18:28:32 +0200 Subject: [PATCH 1/2] Set apiVersion and languageVersion to 2.0 to ensure backwards compatibility --- build.gradle.kts | 13 +++++++++++++ okhttp/api/android/okhttp.api | 2 +- okhttp/api/jvm/okhttp.api | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index aa96ba569379..5b765a73b6e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -195,6 +195,19 @@ subprojects { } } + // Configure all projects' source sets (jvm and kmp) + plugins.matching { it.javaClass.name.startsWith("org.jetbrains.kotlin") }.configureEach { + kotlinExtension.sourceSets { + // Exclude all test source sets (containing Test) + matching { !it.name.contains("Test", ignoreCase = true) }.all { + languageSettings { + apiVersion = "2.0" + languageVersion = "2.0" + } + } + } + } + val platform = System.getProperty("okhttp.platform", "jdk9") val testJavaVersion = System.getProperty("test.java.version", "21").toInt() diff --git a/okhttp/api/android/okhttp.api b/okhttp/api/android/okhttp.api index 1f0b9839ac73..80bd7c8a110a 100644 --- a/okhttp/api/android/okhttp.api +++ b/okhttp/api/android/okhttp.api @@ -1241,7 +1241,7 @@ public abstract interface class okhttp3/TrailersSource { public static final field Companion Lokhttp3/TrailersSource$Companion; public static final field EMPTY Lokhttp3/TrailersSource; public abstract fun get ()Lokhttp3/Headers; - public fun peek ()Lokhttp3/Headers; + public abstract fun peek ()Lokhttp3/Headers; } public final class okhttp3/TrailersSource$Companion { diff --git a/okhttp/api/jvm/okhttp.api b/okhttp/api/jvm/okhttp.api index ca4df1afdcfa..ff226222cb99 100644 --- a/okhttp/api/jvm/okhttp.api +++ b/okhttp/api/jvm/okhttp.api @@ -1240,7 +1240,7 @@ public abstract interface class okhttp3/TrailersSource { public static final field Companion Lokhttp3/TrailersSource$Companion; public static final field EMPTY Lokhttp3/TrailersSource; public abstract fun get ()Lokhttp3/Headers; - public fun peek ()Lokhttp3/Headers; + public abstract fun peek ()Lokhttp3/Headers; } public final class okhttp3/TrailersSource$Companion { From fe29f58912a30899157d9444fc994a4a1a64b204 Mon Sep 17 00:00:00 2001 From: Yuri Schimke Date: Wed, 26 Nov 2025 08:00:39 +0000 Subject: [PATCH 2/2] Update build.gradle.kts Co-authored-by: Zongle Wang --- build.gradle.kts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5b765a73b6e8..3b3e4220383c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -195,16 +195,14 @@ subprojects { } } - // Configure all projects' source sets (jvm and kmp) - plugins.matching { it.javaClass.name.startsWith("org.jetbrains.kotlin") }.configureEach { - kotlinExtension.sourceSets { - // Exclude all test source sets (containing Test) - matching { !it.name.contains("Test", ignoreCase = true) }.all { - languageSettings { - apiVersion = "2.0" - languageVersion = "2.0" - } - } + tasks.withType().configureEach { + if (name.contains("test")) return@configureEach // Skip test source sets. + + compilerOptions { + // Pin language level to 2.0 to ensure compatibility with older Gradle versions and other libraries that depend on okhttp. + // https://docs.gradle.org/current/userguide/compatibility.html#kotlin + languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0 + apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0 } }