From a20e9ae0ede8869a957db917d04c01e039c24efb Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Wed, 25 Dec 2019 17:18:32 +0300 Subject: [PATCH] [Gradle, JS] Extract hack for Native and JS IR compiler - IR to klib compiler needs all dependencies (including transitive implementations) - move hack from native to common with extracting to protected fun --- .../gradle/plugin/KotlinTargetConfigurator.kt | 13 +++++++++++++ .../targets/js/ir/KotlinJsIrTargetConfigurator.kt | 5 +++++ .../native/KotlinNativeTargetConfigurator.kt | 10 +--------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt index d9fb3a26b23..9c6fae68ab8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt @@ -206,6 +206,19 @@ abstract class AbstractKotlinTargetConfigurator } } + @Deprecated("Remove when IR compiler to klib will not need transitive implementation dependencies") + protected fun implementationToApiElements(target: KotlinTargetType) { + val configurations = target.project.configurations + + // The configuration and the main compilation are created by the base class. + val mainCompilation = target.compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME) + configurations.getByName(target.apiElementsConfigurationName).apply { + // K/N and K/JS IR compiler doesn't divide libraries into implementation and api ones. So we need to add implementation + // dependencies into the outgoing configuration. + extendsFrom(configurations.getByName(mainCompilation.implementationConfigurationName)) + } + } + override fun configureBuild(target: KotlinTargetType) { val project = target.project diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt index c25d5448b2a..21814109f7e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt @@ -62,4 +62,9 @@ open class KotlinJsIrTargetConfigurator(kotlinPluginVersion: String) : } } } + + override fun defineConfigurationsForTarget(target: KotlinJsIrTarget) { + super.defineConfigurationsForTarget(target) + implementationToApiElements(target) + } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt index 20b83e2ccde..b8c0d80abdd 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt @@ -324,15 +324,7 @@ open class KotlinNativeTargetConfigurator( override fun defineConfigurationsForTarget(target: T) { super.defineConfigurationsForTarget(target) - val configurations = target.project.configurations - - // The configuration and the main compilation are created by the base class. - val mainCompilation = target.compilations.getByName(MAIN_COMPILATION_NAME) - configurations.getByName(target.apiElementsConfigurationName).apply { - // K/N compiler doesn't divide libraries into implementation and api ones. So we need to add implementation - // dependencies into the outgoing configuration. - extendsFrom(configurations.getByName(mainCompilation.implementationConfigurationName)) - } + implementationToApiElements(target) } private fun warnAboutIncorrectDependencies(target: KotlinNativeTarget) = target.project.whenEvaluated {