diff --git a/android-test/build.gradle.kts b/android-test/build.gradle.kts index 1dc021fd47b2..748c82175ee8 100644 --- a/android-test/build.gradle.kts +++ b/android-test/build.gradle.kts @@ -60,8 +60,10 @@ android { dependencies { implementation(libs.kotlin.reflect) implementation(libs.playservices.safetynet) - implementation(projects.okhttp) + "friendsImplementation"(projects.okhttp) + "friendsImplementation"(projects.okhttpDnsoverhttps) + testImplementation(projects.okhttp) testImplementation(libs.junit) testImplementation(libs.junit.ktx) testImplementation(libs.assertk) diff --git a/build.gradle.kts b/build.gradle.kts index dd647ba4fe41..006164189da0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -279,6 +279,30 @@ subprojects { languageSettings.optIn("okhttp3.ExperimentalOkHttpApi") } } + + // From https://www.liutikas.net/2025/01/12/Kotlin-Library-Friends.html + + // Create configurations we can use to track friend libraries + val friendsApi = configurations.create("friendsApi") { + isCanBeResolved = true + isCanBeConsumed = false + isTransitive = true + } + val friendsImplementation = configurations.create("friendsImplementation") { + isCanBeResolved = true + isCanBeConsumed = false + isTransitive = false + } + + // Make sure friends libraries are on the classpath + configurations.findByName("implementation")?.extendsFrom(friendsApi) + configurations.findByName("implementation")?.extendsFrom(friendsImplementation) + + // Make these libraries friends :) + tasks.withType().configureEach { + friendPaths.from(friendsApi.incoming.artifactView { }.files) + friendPaths.from(friendsImplementation.incoming.artifactView { }.files) + } } /** Configure publishing and signing for published Java and JavaPlatform subprojects. */ diff --git a/mockwebserver-deprecated/build.gradle.kts b/mockwebserver-deprecated/build.gradle.kts index b646bc09cb10..76ecee9b654f 100644 --- a/mockwebserver-deprecated/build.gradle.kts +++ b/mockwebserver-deprecated/build.gradle.kts @@ -15,7 +15,7 @@ tasks.jar { } dependencies { - api(projects.okhttp) + "friendsApi"(projects.okhttp) api(projects.mockwebserver3) api(libs.junit) diff --git a/mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/MockResponse.kt b/mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/MockResponse.kt index 9c8d33ef7ebb..5f6d04472b68 100644 --- a/mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/MockResponse.kt +++ b/mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/MockResponse.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.mockwebserver diff --git a/mockwebserver-junit4/build.gradle.kts b/mockwebserver-junit4/build.gradle.kts index 389710bbe6d4..adc6c3e15ae4 100644 --- a/mockwebserver-junit4/build.gradle.kts +++ b/mockwebserver-junit4/build.gradle.kts @@ -15,6 +15,7 @@ tasks.jar { } dependencies { + api(projects.okhttp) api(projects.mockwebserver3) api(libs.junit) diff --git a/mockwebserver-junit5/build.gradle.kts b/mockwebserver-junit5/build.gradle.kts index 73de96017794..0dac973bdb9f 100644 --- a/mockwebserver-junit5/build.gradle.kts +++ b/mockwebserver-junit5/build.gradle.kts @@ -21,6 +21,7 @@ tasks { } dependencies { + api(projects.okhttp) api(projects.mockwebserver3) api(libs.junit.jupiter.api) compileOnly(libs.animalsniffer.annotations) diff --git a/mockwebserver/build.gradle.kts b/mockwebserver/build.gradle.kts index b50cd4c8c374..aea7d950abc4 100644 --- a/mockwebserver/build.gradle.kts +++ b/mockwebserver/build.gradle.kts @@ -15,7 +15,7 @@ tasks.jar { } dependencies { - api(projects.okhttp) + "friendsApi"(projects.okhttp) testImplementation(projects.okhttpTestingSupport) testImplementation(projects.okhttpTls) diff --git a/mockwebserver/src/main/kotlin/mockwebserver3/MockResponse.kt b/mockwebserver/src/main/kotlin/mockwebserver3/MockResponse.kt index 7160c7294a3c..86add2eead32 100644 --- a/mockwebserver/src/main/kotlin/mockwebserver3/MockResponse.kt +++ b/mockwebserver/src/main/kotlin/mockwebserver3/MockResponse.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package mockwebserver3 diff --git a/mockwebserver/src/main/kotlin/mockwebserver3/MockWebServer.kt b/mockwebserver/src/main/kotlin/mockwebserver3/MockWebServer.kt index 78205b7c5cde..0ce1fe779d08 100644 --- a/mockwebserver/src/main/kotlin/mockwebserver3/MockWebServer.kt +++ b/mockwebserver/src/main/kotlin/mockwebserver3/MockWebServer.kt @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package mockwebserver3 diff --git a/mockwebserver/src/test/java/mockwebserver3/RecordedRequestTest.kt b/mockwebserver/src/test/java/mockwebserver3/RecordedRequestTest.kt index 9b6a24cf082e..76047d718c5e 100644 --- a/mockwebserver/src/test/java/mockwebserver3/RecordedRequestTest.kt +++ b/mockwebserver/src/test/java/mockwebserver3/RecordedRequestTest.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package mockwebserver3 diff --git a/okhttp-dnsoverhttps/build.gradle.kts b/okhttp-dnsoverhttps/build.gradle.kts index 5232ce6b68bd..818c8c9d63ae 100644 --- a/okhttp-dnsoverhttps/build.gradle.kts +++ b/okhttp-dnsoverhttps/build.gradle.kts @@ -15,7 +15,7 @@ project.applyOsgi( ) dependencies { - api(projects.okhttp) + "friendsApi"(projects.okhttp) compileOnly(libs.findbugs.jsr305) testImplementation(projects.okhttpTestingSupport) diff --git a/okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/DnsOverHttps.kt b/okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/DnsOverHttps.kt index f164e23b863f..65556fe40750 100644 --- a/okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/DnsOverHttps.kt +++ b/okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/DnsOverHttps.kt @@ -205,16 +205,17 @@ class DnsOverHttps internal constructor( Request.Builder().header("Accept", DNS_MESSAGE.toString()).apply { val query = DnsRecordCodec.encodeQuery(hostname, type) + val dnsUrl: HttpUrl = this@DnsOverHttps.url if (post) { - url(url) + url(dnsUrl) .cacheUrlOverride( - url.newBuilder() + dnsUrl.newBuilder() .addQueryParameter("hostname", hostname).build(), ) .post(query.toRequestBody(DNS_MESSAGE)) } else { val encoded = query.base64Url().replace("=", "") - val requestUrl = url.newBuilder().addQueryParameter("dns", encoded).build() + val requestUrl = dnsUrl.newBuilder().addQueryParameter("dns", encoded).build() url(requestUrl) } diff --git a/okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsRecordCodecTest.kt b/okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsRecordCodecTest.kt index 7e29c5da611a..3d598da0a337 100644 --- a/okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsRecordCodecTest.kt +++ b/okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsRecordCodecTest.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.dnsoverhttps diff --git a/okhttp-java-net-cookiejar/build.gradle.kts b/okhttp-java-net-cookiejar/build.gradle.kts index 5d74471a86f3..43a465412063 100644 --- a/okhttp-java-net-cookiejar/build.gradle.kts +++ b/okhttp-java-net-cookiejar/build.gradle.kts @@ -15,7 +15,7 @@ project.applyOsgi( ) dependencies { - api(projects.okhttp) + "friendsApi"(projects.okhttp) compileOnly(libs.findbugs.jsr305) compileOnly(libs.animalsniffer.annotations) } diff --git a/okhttp-java-net-cookiejar/src/main/kotlin/okhttp3/java/net/cookiejar/JavaNetCookieJar.kt b/okhttp-java-net-cookiejar/src/main/kotlin/okhttp3/java/net/cookiejar/JavaNetCookieJar.kt index 3c4d94d4d3eb..a629f7584fcf 100644 --- a/okhttp-java-net-cookiejar/src/main/kotlin/okhttp3/java/net/cookiejar/JavaNetCookieJar.kt +++ b/okhttp-java-net-cookiejar/src/main/kotlin/okhttp3/java/net/cookiejar/JavaNetCookieJar.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.java.net.cookiejar diff --git a/okhttp-logging-interceptor/build.gradle.kts b/okhttp-logging-interceptor/build.gradle.kts index 69fe384620b1..23308c9083c3 100644 --- a/okhttp-logging-interceptor/build.gradle.kts +++ b/okhttp-logging-interceptor/build.gradle.kts @@ -15,7 +15,7 @@ project.applyOsgi( ) dependencies { - api(projects.okhttp) + "friendsApi"(projects.okhttp) compileOnly(libs.findbugs.jsr305) testCompileOnly(libs.findbugs.jsr305) diff --git a/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt b/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt index 99bcfc58ab68..b50ac74c3e7b 100644 --- a/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt +++ b/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.logging diff --git a/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt b/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt index dd73d7b418b5..1f989c5b1fb5 100644 --- a/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt +++ b/okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt @@ -906,7 +906,6 @@ class HttpLoggingInterceptorTest { .assertNoMoreLogs() } - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @Test fun sensitiveQueryParamsAreRedacted() { url = server.url("/api/login?user=test_user&authentication=basic&password=confidential_password") @@ -951,7 +950,6 @@ class HttpLoggingInterceptorTest { .assertNoMoreLogs() } - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @Test fun preserveQueryParamsAfterRedacted() { url = diff --git a/okhttp-testing-support/build.gradle.kts b/okhttp-testing-support/build.gradle.kts index 87c287063693..6eb67a476628 100644 --- a/okhttp-testing-support/build.gradle.kts +++ b/okhttp-testing-support/build.gradle.kts @@ -5,7 +5,7 @@ plugins { dependencies { api(libs.squareup.okio) - api(projects.okhttp) + "friendsApi"(projects.okhttp) api(projects.okhttpTls) api(libs.assertk) api(libs.bouncycastle.bcprov) diff --git a/okhttp-testing-support/src/main/kotlin/okhttp3/CallEvent.kt b/okhttp-testing-support/src/main/kotlin/okhttp3/CallEvent.kt index 3bf1afe733ed..0cf43e0cd465 100644 --- a/okhttp-testing-support/src/main/kotlin/okhttp3/CallEvent.kt +++ b/okhttp-testing-support/src/main/kotlin/okhttp3/CallEvent.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3 diff --git a/okhttp-testing-support/src/main/kotlin/okhttp3/ConnectionEvent.kt b/okhttp-testing-support/src/main/kotlin/okhttp3/ConnectionEvent.kt index 0da52ea65898..2dded160c909 100644 --- a/okhttp-testing-support/src/main/kotlin/okhttp3/ConnectionEvent.kt +++ b/okhttp-testing-support/src/main/kotlin/okhttp3/ConnectionEvent.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3 diff --git a/okhttp-testing-support/src/main/kotlin/okhttp3/OkHttpClientTestRule.kt b/okhttp-testing-support/src/main/kotlin/okhttp3/OkHttpClientTestRule.kt index 8d222346e88e..3eddae6b329d 100644 --- a/okhttp-testing-support/src/main/kotlin/okhttp3/OkHttpClientTestRule.kt +++ b/okhttp-testing-support/src/main/kotlin/okhttp3/OkHttpClientTestRule.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3 diff --git a/okhttp-testing-support/src/main/kotlin/okhttp3/TestValueFactory.kt b/okhttp-testing-support/src/main/kotlin/okhttp3/TestValueFactory.kt index de57c4c5861f..c5013b5b3bfd 100644 --- a/okhttp-testing-support/src/main/kotlin/okhttp3/TestValueFactory.kt +++ b/okhttp-testing-support/src/main/kotlin/okhttp3/TestValueFactory.kt @@ -13,11 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress( - "CANNOT_OVERRIDE_INVISIBLE_MEMBER", - "INVISIBLE_MEMBER", - "INVISIBLE_REFERENCE", -) package okhttp3 diff --git a/okhttp-testing-support/src/main/kotlin/okhttp3/internal/concurrent/TaskFaker.kt b/okhttp-testing-support/src/main/kotlin/okhttp3/internal/concurrent/TaskFaker.kt index cfb099be2e0d..de4a31570f36 100644 --- a/okhttp-testing-support/src/main/kotlin/okhttp3/internal/concurrent/TaskFaker.kt +++ b/okhttp-testing-support/src/main/kotlin/okhttp3/internal/concurrent/TaskFaker.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.internal.concurrent @@ -369,6 +368,8 @@ class TaskFaker : Closeable { val editCountBefore = editCount yieldUntil { nanoTime >= waitUntil || editCount > editCountBefore } } + // TODO report compiler bug + TODO("Can't get here") } } diff --git a/okhttp-testing-support/src/main/kotlin/okhttp3/internal/http/RecordingProxySelector.kt b/okhttp-testing-support/src/main/kotlin/okhttp3/internal/http/RecordingProxySelector.kt index a51e8afb74de..ecf8db8e761c 100644 --- a/okhttp-testing-support/src/main/kotlin/okhttp3/internal/http/RecordingProxySelector.kt +++ b/okhttp-testing-support/src/main/kotlin/okhttp3/internal/http/RecordingProxySelector.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.internal.http diff --git a/okhttp-tls/build.gradle.kts b/okhttp-tls/build.gradle.kts index 948fb4df3647..9ddcd90063c8 100644 --- a/okhttp-tls/build.gradle.kts +++ b/okhttp-tls/build.gradle.kts @@ -17,7 +17,7 @@ project.applyOsgi( dependencies { api(libs.squareup.okio) - implementation(projects.okhttp) + "friendsImplementation"(projects.okhttp) compileOnly(libs.findbugs.jsr305) compileOnly(libs.animalsniffer.annotations) diff --git a/okhttp-tls/src/main/kotlin/okhttp3/tls/HandshakeCertificates.kt b/okhttp-tls/src/main/kotlin/okhttp3/tls/HandshakeCertificates.kt index b562d896064f..c9ae5a342c6f 100644 --- a/okhttp-tls/src/main/kotlin/okhttp3/tls/HandshakeCertificates.kt +++ b/okhttp-tls/src/main/kotlin/okhttp3/tls/HandshakeCertificates.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.tls diff --git a/okhttp-tls/src/main/kotlin/okhttp3/tls/internal/InsecureExtendedTrustManager.kt b/okhttp-tls/src/main/kotlin/okhttp3/tls/internal/InsecureExtendedTrustManager.kt index 9b2e27edd398..36ad28977056 100644 --- a/okhttp-tls/src/main/kotlin/okhttp3/tls/internal/InsecureExtendedTrustManager.kt +++ b/okhttp-tls/src/main/kotlin/okhttp3/tls/internal/InsecureExtendedTrustManager.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3.tls.internal diff --git a/okhttp-urlconnection/build.gradle.kts b/okhttp-urlconnection/build.gradle.kts index 587be51048f5..dad3b2f09d23 100644 --- a/okhttp-urlconnection/build.gradle.kts +++ b/okhttp-urlconnection/build.gradle.kts @@ -16,7 +16,7 @@ project.applyOsgi( ) dependencies { - api(projects.okhttp) + "friendsApi"(projects.okhttp) api(projects.okhttpJavaNetCookiejar) compileOnly(libs.findbugs.jsr305) compileOnly(libs.animalsniffer.annotations) diff --git a/okhttp-urlconnection/src/main/kotlin/okhttp3/JavaNetCookieJar.kt b/okhttp-urlconnection/src/main/kotlin/okhttp3/JavaNetCookieJar.kt index e9d1b3c4b483..acba78d098ae 100644 --- a/okhttp-urlconnection/src/main/kotlin/okhttp3/JavaNetCookieJar.kt +++ b/okhttp-urlconnection/src/main/kotlin/okhttp3/JavaNetCookieJar.kt @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package okhttp3 diff --git a/samples/guide/build.gradle.kts b/samples/guide/build.gradle.kts index be8a0003d563..87240f20b74f 100644 --- a/samples/guide/build.gradle.kts +++ b/samples/guide/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } dependencies { - implementation(projects.okhttp) + "friendsImplementation"(projects.okhttp) implementation(projects.mockwebserver) implementation(projects.okhttpTestingSupport) implementation(projects.okhttpTls) diff --git a/samples/guide/src/main/java/okhttp3/recipes/kt/WiresharkExample.kt b/samples/guide/src/main/java/okhttp3/recipes/kt/WiresharkExample.kt index cfb08e789258..9c2c84d45e91 100644 --- a/samples/guide/src/main/java/okhttp3/recipes/kt/WiresharkExample.kt +++ b/samples/guide/src/main/java/okhttp3/recipes/kt/WiresharkExample.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "Since15") +@file:Suppress("Since15") package okhttp3.recipes.kt diff --git a/samples/guide/src/main/java/okhttp3/recipes/kt/YubikeyClientAuth.kt b/samples/guide/src/main/java/okhttp3/recipes/kt/YubikeyClientAuth.kt index 466e5d62922e..5e0360ce215f 100644 --- a/samples/guide/src/main/java/okhttp3/recipes/kt/YubikeyClientAuth.kt +++ b/samples/guide/src/main/java/okhttp3/recipes/kt/YubikeyClientAuth.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "Since15") +@file:Suppress("Since15") package okhttp3.recipes.kt diff --git a/samples/slack/build.gradle.kts b/samples/slack/build.gradle.kts index dacdc08fc669..dfb40bad2b1c 100644 --- a/samples/slack/build.gradle.kts +++ b/samples/slack/build.gradle.kts @@ -3,6 +3,7 @@ plugins { } dependencies { + implementation(projects.okhttp) implementation(projects.mockwebserver) implementation(libs.squareup.moshi) } diff --git a/samples/static-server/build.gradle.kts b/samples/static-server/build.gradle.kts index f27bf93c0872..234895cebaaa 100644 --- a/samples/static-server/build.gradle.kts +++ b/samples/static-server/build.gradle.kts @@ -14,6 +14,7 @@ tasks.jar { } dependencies { + implementation(projects.okhttp) implementation(projects.mockwebserver) }