Correctly import 'implements' dependencies on root project
This commit is contained in:
+43
@@ -66,6 +66,49 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
|
||||
assertModuleModuleDepScope("js_test", "common_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlatformToCommonDependencyRoot() {
|
||||
createProjectSubFile("settings.gradle", "rootProject.name = 'foo'\ninclude ':jvm', ':js'")
|
||||
|
||||
val kotlinVersion = "1.1.0"
|
||||
|
||||
createProjectSubFile("build.gradle", """
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
|
||||
project('jvm') {
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
dependencies {
|
||||
implement project(':')
|
||||
}
|
||||
}
|
||||
|
||||
project('js') {
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
dependencies {
|
||||
implement project(':')
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
importProject()
|
||||
assertModuleModuleDepScope("jvm_main", "foo_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("jvm_test", "foo_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_main", "foo_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_test", "foo_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMultiProject() {
|
||||
createProjectSubFile("settings.gradle", "include ':common-lib', ':jvm-lib', ':js-lib', ':common-app', ':jvm-app', ':js-app'")
|
||||
|
||||
@@ -89,7 +89,7 @@ class KotlinGradleModelBuilder : ModelBuilderService {
|
||||
toProcess.add(startingProject)
|
||||
val processed = HashSet<String>()
|
||||
val result = HashSet<String>()
|
||||
result.add(startingProject.path)
|
||||
result.add(startingProject.pathOrName())
|
||||
|
||||
while (toProcess.isNotEmpty()) {
|
||||
val project = toProcess.pollFirst()
|
||||
@@ -97,7 +97,7 @@ class KotlinGradleModelBuilder : ModelBuilderService {
|
||||
|
||||
if (!project.plugins.hasPlugin(kotlinPlatformCommonPluginId)) continue
|
||||
|
||||
result.add(project.path)
|
||||
result.add(project.pathOrName())
|
||||
|
||||
val compileConfiguration = project.configurations.findByName("compile") ?: continue
|
||||
val dependencies = compileConfiguration
|
||||
@@ -115,6 +115,9 @@ class KotlinGradleModelBuilder : ModelBuilderService {
|
||||
return result
|
||||
}
|
||||
|
||||
// see GradleProjectResolverUtil.getModuleId() in IDEA codebase
|
||||
private fun Project.pathOrName() = if (path == ":") name else path
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun Task.getCompilerArguments(methodName: String): List<String> {
|
||||
return try {
|
||||
|
||||
Reference in New Issue
Block a user