[Gradle, JS] Hack for npm resolving of js mixed mode
This commit is contained in:
+4
-4
@@ -184,10 +184,10 @@ internal class KotlinCompilationNpmResolver(
|
|||||||
val dependentProject = project.findProject(componentIdentifier.projectPath)
|
val dependentProject = project.findProject(componentIdentifier.projectPath)
|
||||||
?: error("Cannot find project ${componentIdentifier.projectPath}")
|
?: error("Cannot find project ${componentIdentifier.projectPath}")
|
||||||
|
|
||||||
val dependentResolver = resolver.findDependentResolver(project, dependentProject)
|
resolver.findDependentResolver(project, dependentProject)
|
||||||
if (dependentResolver != null) {
|
?.forEach { dependentResolver ->
|
||||||
internalDependencies.add(dependentResolver)
|
internalDependencies.add(dependentResolver)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
externalGradleDependencies.add(ExternalGradleDependency(dependency, artifact))
|
externalGradleDependencies.add(ExternalGradleDependency(dependency, artifact))
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-3
@@ -9,6 +9,7 @@ import org.gradle.api.Project
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dukat.DukatRootResolverPlugin
|
import org.jetbrains.kotlin.gradle.targets.js.dukat.DukatRootResolverPlugin
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
|
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.GradleNodeModulesCache
|
import org.jetbrains.kotlin.gradle.targets.js.npm.GradleNodeModulesCache
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager
|
import org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager
|
||||||
@@ -51,20 +52,31 @@ internal class KotlinRootNpmResolver internal constructor(
|
|||||||
val compilations: Collection<KotlinJsCompilation>
|
val compilations: Collection<KotlinJsCompilation>
|
||||||
get() = projectResolvers.values.flatMap { it.compilationResolvers.map { it.compilation } }
|
get() = projectResolvers.values.flatMap { it.compilationResolvers.map { it.compilation } }
|
||||||
|
|
||||||
fun findDependentResolver(src: Project, target: Project): KotlinCompilationNpmResolver? {
|
fun findDependentResolver(src: Project, target: Project): List<KotlinCompilationNpmResolver>? {
|
||||||
// todo: proper finding using KotlinTargetComponent.findUsageContext
|
// todo: proper finding using KotlinTargetComponent.findUsageContext
|
||||||
val targetResolver = this[target]
|
val targetResolver = this[target]
|
||||||
val mainCompilations = targetResolver.compilationResolvers.filter { it.compilation.name == KotlinCompilation.MAIN_COMPILATION_NAME }
|
val mainCompilations = targetResolver.compilationResolvers.filter { it.compilation.name == KotlinCompilation.MAIN_COMPILATION_NAME }
|
||||||
|
|
||||||
return if (mainCompilations.isNotEmpty()) {
|
return if (mainCompilations.isNotEmpty()) {
|
||||||
if (mainCompilations.size > 1) {
|
//TODO[Ilya Goncharov] Hack for Mixed mode of legacy and IR tooling
|
||||||
|
if (mainCompilations.size == 2) {
|
||||||
|
check(
|
||||||
|
mainCompilations[0].compilation is KotlinJsIrCompilation
|
||||||
|
|| mainCompilations[1].compilation is KotlinJsIrCompilation
|
||||||
|
) {
|
||||||
|
"Cannot resolve project dependency $src -> $target." +
|
||||||
|
"Dependency to project with multiple js compilation not supported yet."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainCompilations.size > 2) {
|
||||||
error(
|
error(
|
||||||
"Cannot resolve project dependency $src -> $target." +
|
"Cannot resolve project dependency $src -> $target." +
|
||||||
"Dependency to project with multiple js compilation not supported yet."
|
"Dependency to project with multiple js compilation not supported yet."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
mainCompilations.single()
|
mainCompilations
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user