Correctly detect library kind when not using modules per sourceset
#KT-19219 Fixed
This commit is contained in:
@@ -123,6 +123,7 @@ private fun findOwnerModule(libraryData: LibraryData,
|
|||||||
projectDataNode: DataNode<ProjectData>): DataNode<ModuleData>? {
|
projectDataNode: DataNode<ProjectData>): DataNode<ModuleData>? {
|
||||||
return projectDataNode.children.firstOrNull { dataNode ->
|
return projectDataNode.children.firstOrNull { dataNode ->
|
||||||
if (dataNode.data !is ModuleData) return@firstOrNull false
|
if (dataNode.data !is ModuleData) return@firstOrNull false
|
||||||
|
if (dataNode.hasDependency(libraryData)) return@firstOrNull true
|
||||||
val sourceSetDataNodes = dataNode.children.filter { it.data is GradleSourceSetData }
|
val sourceSetDataNodes = dataNode.children.filter { it.data is GradleSourceSetData }
|
||||||
sourceSetDataNodes.any { it.hasDependency(libraryData) }
|
sourceSetDataNodes.any { it.hasDependency(libraryData) }
|
||||||
} as DataNode<ModuleData>?
|
} as DataNode<ModuleData>?
|
||||||
|
|||||||
@@ -694,6 +694,48 @@ compileTestKotlin {
|
|||||||
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
|
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testCommonImportByPlatformPlugin_SingleModule() {
|
||||||
|
createProjectSubFile("build.gradle", """
|
||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
""")
|
||||||
|
importProjectUsingSingeModulePerGradleProject()
|
||||||
|
|
||||||
|
with (facetSettings("project")) {
|
||||||
|
Assert.assertEquals("1.1", languageLevel!!.versionString)
|
||||||
|
Assert.assertEquals("1.1", apiLevel!!.versionString)
|
||||||
|
Assert.assertEquals(TargetPlatformKind.Common, targetPlatformKind)
|
||||||
|
}
|
||||||
|
|
||||||
|
val rootManager = ModuleRootManager.getInstance(getModule("project"))
|
||||||
|
val stdlib = rootManager.orderEntries.filterIsInstance<LibraryOrderEntry>().mapTo(HashSet()) { it.library }.single()
|
||||||
|
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testJvmImportByKotlinPlugin() {
|
fun testJvmImportByKotlinPlugin() {
|
||||||
createProjectSubFile("build.gradle", """
|
createProjectSubFile("build.gradle", """
|
||||||
|
|||||||
@@ -154,6 +154,11 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes
|
|||||||
return "build.gradle";
|
return "build.gradle";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void importProjectUsingSingeModulePerGradleProject() {
|
||||||
|
getCurrentExternalProjectSettings().setResolveModulePerSourceSet(false);
|
||||||
|
importProject();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void importProject() {
|
protected void importProject() {
|
||||||
ExternalSystemApiUtil.subscribe(myProject, GradleConstants.SYSTEM_ID, new ExternalSystemSettingsListenerAdapter() {
|
ExternalSystemApiUtil.subscribe(myProject, GradleConstants.SYSTEM_ID, new ExternalSystemSettingsListenerAdapter() {
|
||||||
|
|||||||
Reference in New Issue
Block a user