fix import of expectedBy scope dependencies inside composite builds
This commit is contained in:
committed by
asedunov
parent
8ac7f0b592
commit
b1419e2a8c
+13
-4
@@ -134,9 +134,18 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
gradleIdeaProject.modules.firstOrNull { it.gradleProject.path == moduleNodeForGradleModel?.data?.id }
|
||||
}
|
||||
else gradleModule
|
||||
val implementsModuleId = resolverCtx.getExtraProject(ideaModule, KotlinGradleModel::class.java)?.implements
|
||||
|
||||
val implementsInfo = resolverCtx.getExtraProject(ideaModule, KotlinGradleModel::class.java)?.implements
|
||||
val targetModule = implementsInfo?.let { findModule(ideProject, it) }
|
||||
val targetModule = implementsModuleId?.let {
|
||||
val compositePrefix = if (resolverCtx.models.ideaProject != gradleModule.project
|
||||
&& it.startsWith(":")) {
|
||||
gradleModule.project.name
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
findModuleById(ideProject, compositePrefix + it)
|
||||
}
|
||||
if (targetModule != null) {
|
||||
if (useModulePerSourceSet()) {
|
||||
val targetSourceSetsByName = ExternalSystemApiUtil
|
||||
@@ -184,7 +193,7 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
ideProject: DataNode<ProjectData>,
|
||||
gradleModel: KotlinGradleModel
|
||||
) {
|
||||
val implementedModule = gradleModel.implements?.let { findModule(ideProject, it) } ?: return
|
||||
val implementedModule = gradleModel.implements?.let { findModuleById(ideProject, it) } ?: return
|
||||
if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
val dependentSourceSets = dependentModule.getSourceSetsMap()
|
||||
val implementedSourceSets = implementedModule.getSourceSetsMap()
|
||||
@@ -211,7 +220,7 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
ideModule.createChild(ProjectKeys.MODULE_DEPENDENCY, moduleDependencyData)
|
||||
}
|
||||
|
||||
private fun findModule(ideProject: DataNode<ProjectData>, moduleId: String): DataNode<ModuleData>? {
|
||||
private fun findModuleById(ideProject: DataNode<ProjectData>, moduleId: String): DataNode<ModuleData>? {
|
||||
return ideProject.children.find { (it.data as? ModuleData)?.id == moduleId } as DataNode<ModuleData>?
|
||||
}
|
||||
}
|
||||
|
||||
+62
@@ -118,6 +118,68 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
|
||||
assertModuleModuleDepScope("js_test", "common_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlatformToCommonExpectedByDependencyInComposite() {
|
||||
createProjectSubFile("toInclude/settings.gradle", "include ':common', ':jvm', ':js'")
|
||||
|
||||
val kotlinVersion = "1.2.0-beta-74"
|
||||
|
||||
createProjectSubFile("toInclude/build.gradle", """
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'http://dl.bintray.com/kotlin/kotlin-dev' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
project('common') {
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
}
|
||||
|
||||
project('jvm') {
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(':common')
|
||||
}
|
||||
}
|
||||
|
||||
project('js') {
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(':common')
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
createProjectSubFile("settings.gradle", "includeBuild('toInclude')")
|
||||
createProjectSubFile("build.gradle", """
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'http://dl.bintray.com/kotlin/kotlin-dev' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
""".trimIndent())
|
||||
|
||||
importProject()
|
||||
assertModuleModuleDepScope("jvm_main", "common_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("jvm_test", "common_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_main", "common_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_test", "common_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlatformToCommonDependencyRoot() {
|
||||
createProjectSubFile("settings.gradle", "rootProject.name = 'foo'\ninclude ':jvm', ':js'")
|
||||
|
||||
Reference in New Issue
Block a user