@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
10
10
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
11
11
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
12
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
13
+ import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation
13
14
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
14
15
import java.net.URI
15
16
@@ -289,27 +290,37 @@ subprojects {
289
290
290
291
// From https://www.liutikas.net/2025/01/12/Kotlin-Library-Friends.html
291
292
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
+ }
302
313
}
303
314
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
+ }
313
324
}
314
325
315
326
/* * Configure publishing and signing for published Java and JavaPlatform subprojects. */
0 commit comments