Skip to content

Commit 36cbca4

Browse files
committed
Fixes
1 parent 85ee0f5 commit 36cbca4

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

build.gradle.kts

+30-19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1010
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
1111
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
1212
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
13+
import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation
1314
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
1415
import java.net.URI
1516

@@ -289,27 +290,37 @@ subprojects {
289290

290291
// From https://www.liutikas.net/2025/01/12/Kotlin-Library-Friends.html
291292

292-
// Create configurations we can use to track friend libraries
293-
val friendsApi = configurations.create("friendsApi") {
294-
isCanBeResolved = true
295-
isCanBeConsumed = false
296-
isTransitive = true
297-
}
298-
val friendsImplementation = configurations.create("friendsImplementation") {
299-
isCanBeResolved = true
300-
isCanBeConsumed = false
301-
isTransitive = false
293+
// Create configurations we can use to track friend libraries
294+
configurations {
295+
val friendsApi = register("friendsApi") {
296+
isCanBeResolved = true
297+
isCanBeConsumed = false
298+
isTransitive = true
299+
}
300+
val friendsImplementation = register("friendsImplementation") {
301+
isCanBeResolved = true
302+
isCanBeConsumed = false
303+
isTransitive = false
304+
}
305+
configurations.configureEach {
306+
if (name == "implementation") {
307+
extendsFrom(friendsApi.get(), friendsImplementation.get())
308+
}
309+
if (name == "api") {
310+
extendsFrom(friendsApi.get())
311+
}
312+
}
302313
}
303314

304-
// Make sure friends libraries are on the classpath
305-
configurations.findByName("implementation")?.extendsFrom(friendsApi)
306-
configurations.findByName("implementation")?.extendsFrom(friendsImplementation)
307-
308-
// Make these libraries friends :)
309-
tasks.withType<KotlinCompile>().configureEach {
310-
friendPaths.from(friendsApi.incoming.artifactView { }.files)
311-
friendPaths.from(friendsImplementation.incoming.artifactView { }.files)
312-
}
315+
// Make these libraries friends :)
316+
tasks.withType<KotlinCompile>().configureEach {
317+
configurations.findByName("friendsApi")?.let {
318+
friendPaths.from(it.incoming.artifactView { }.files)
319+
}
320+
configurations.findByName("friendsImplementation")?.let {
321+
friendPaths.from(it.incoming.artifactView { }.files)
322+
}
323+
}
313324
}
314325

315326
/** Configure publishing and signing for published Java and JavaPlatform subprojects. */

okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/DnsOverHttps.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,18 @@ class DnsOverHttps internal constructor(
208208
.apply {
209209
val query = DnsRecordCodec.encodeQuery(hostname, type)
210210

211+
val dnsUrl: HttpUrl = this@DnsOverHttps.url
211212
if (post) {
212-
url(url)
213+
url(dnsUrl)
213214
.cacheUrlOverride(
214-
url
215+
dnsUrl
215216
.newBuilder()
216217
.addQueryParameter("hostname", hostname)
217218
.build(),
218219
).post(query.toRequestBody(DNS_MESSAGE))
219220
} else {
220221
val encoded = query.base64Url().replace("=", "")
221-
val requestUrl = url.newBuilder().addQueryParameter("dns", encoded).build()
222+
val requestUrl = dnsUrl.newBuilder().addQueryParameter("dns", encoded).build()
222223

223224
url(requestUrl)
224225
}

0 commit comments

Comments
 (0)