[Gradle] Fix friendArtifactResolver for External Targets API

It was failing with ClassCastException in an attempt of using it.

Also added a test case to cover the logic with friendArtifactResolver

^KT-66431 Verification Pending
This commit is contained in:
Anton Lakotka
2024-03-08 14:45:43 +01:00
committed by Space Team
parent 5873127342
commit e2336e1752
4 changed files with 54 additions and 1 deletions
@@ -7,6 +7,7 @@
package org.jetbrains.kotlin.gradle.android
import org.gradle.api.file.ConfigurableFileCollection
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
@@ -27,5 +28,7 @@ class PrototypeAndroidCompilation(delegate: Delegate) : DecoratedExternalKotlinC
get() = super.compilerOptions as HasCompilerOptions<KotlinJvmCompilerOptions>
var androidCompilationSpecificStuff = 10
val extraFriendPaths: ConfigurableFileCollection = project.files()
}
@@ -25,6 +25,10 @@ internal fun PrototypeAndroidTarget.createAndroidCompilation(name: String): Prot
compilationFactory = CompilationFactory(::PrototypeAndroidCompilation)
compileTaskName = camelCase("prototype", "compile", targetName, name)
friendArtifactResolver = ExternalKotlinCompilationDescriptor.FriendArtifactResolver { compilation ->
compilation.extraFriendPaths
}
/*
Replace Kotlin's compilation association (main <-> test) with noop,
since Android goes through adding a dependency on the project itself