[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
This commit is contained in:
Ilya Goncharov
2019-12-25 17:18:32 +03:00
parent f936a0fc9b
commit a20e9ae0ed
3 changed files with 19 additions and 9 deletions
@@ -206,6 +206,19 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
}
}
@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
@@ -62,4 +62,9 @@ open class KotlinJsIrTargetConfigurator(kotlinPluginVersion: String) :
}
}
}
override fun defineConfigurationsForTarget(target: KotlinJsIrTarget) {
super.defineConfigurationsForTarget(target)
implementationToApiElements(target)
}
}
@@ -324,15 +324,7 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
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 {