Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a friends configuration to use internals. #8651

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion android-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<KotlinCompile>().configureEach {
friendPaths.from(friendsApi.incoming.artifactView { }.files)
friendPaths.from(friendsImplementation.incoming.artifactView { }.files)
}
}

/** Configure publishing and signing for published Java and JavaPlatform subprojects. */
Expand Down
2 changes: 1 addition & 1 deletion mockwebserver-deprecated/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks.jar {
}

dependencies {
api(projects.okhttp)
"friendsApi"(projects.okhttp)
api(projects.mockwebserver3)
api(libs.junit)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions mockwebserver-junit4/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tasks.jar {
}

dependencies {
api(projects.okhttp)
api(projects.mockwebserver3)
api(libs.junit)

Expand Down
1 change: 1 addition & 0 deletions mockwebserver-junit5/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tasks {
}

dependencies {
api(projects.okhttp)
api(projects.mockwebserver3)
api(libs.junit.jupiter.api)
compileOnly(libs.animalsniffer.annotations)
Expand Down
2 changes: 1 addition & 1 deletion mockwebserver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks.jar {
}

dependencies {
api(projects.okhttp)
"friendsApi"(projects.okhttp)

testImplementation(projects.okhttpTestingSupport)
testImplementation(projects.okhttpTls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion okhttp-dnsoverhttps/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friendsApi"(projects.okhttp)
compileOnly(libs.findbugs.jsr305)

testImplementation(projects.okhttpTestingSupport)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [email protected]
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion okhttp-java-net-cookiejar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friendsApi"(projects.okhttp)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.animalsniffer.annotations)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion okhttp-logging-interceptor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friendsApi"(projects.okhttp)
compileOnly(libs.findbugs.jsr305)

testCompileOnly(libs.findbugs.jsr305)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -951,7 +950,6 @@ class HttpLoggingInterceptorTest {
.assertNoMoreLogs()
}

@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Test
fun preserveQueryParamsAfterRedacted() {
url =
Expand Down
2 changes: 1 addition & 1 deletion okhttp-testing-support/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -369,6 +368,8 @@ class TaskFaker : Closeable {
val editCountBefore = editCount
yieldUntil { nanoTime >= waitUntil || editCount > editCountBefore }
}
// TODO report compiler bug
TODO("Can't get here")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion okhttp-tls/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion okhttp-urlconnection/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friendsApi"(projects.okhttp)
api(projects.okhttpJavaNetCookiejar)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.animalsniffer.annotations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion samples/guide/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

dependencies {
implementation(projects.okhttp)
"friendsImplementation"(projects.okhttp)
implementation(projects.mockwebserver)
implementation(projects.okhttpTestingSupport)
implementation(projects.okhttpTls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions samples/slack/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
}

dependencies {
implementation(projects.okhttp)
implementation(projects.mockwebserver)
implementation(libs.squareup.moshi)
}
1 change: 1 addition & 0 deletions samples/static-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tasks.jar {
}

dependencies {
implementation(projects.okhttp)
implementation(projects.mockwebserver)
}

Expand Down
Loading