From a0c105adbefb6ed3020df366a9a90af13c77d493 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Wed, 14 Feb 2018 23:59:28 +0300 Subject: [PATCH] Fixes to make the project compile when using Pill --- buildSrc/src/main/kotlin/pill/parser.kt | 28 +++++++++++-------- .../jetbrains/kotlin/codegen/ScriptGenTest.kt | 2 +- idea/build.gradle.kts | 2 ++ idea/idea-android/build.gradle.kts | 1 + plugins/allopen/allopen-ide/build.gradle.kts | 2 +- plugins/lint/build.gradle.kts | 1 + plugins/noarg/noarg-ide/build.gradle.kts | 2 +- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/buildSrc/src/main/kotlin/pill/parser.kt b/buildSrc/src/main/kotlin/pill/parser.kt index a3064e545ce..634aade6b1f 100644 --- a/buildSrc/src/main/kotlin/pill/parser.kt +++ b/buildSrc/src/main/kotlin/pill/parser.kt @@ -85,16 +85,21 @@ fun parse(project: Project, context: ParserContext): PProject = with (context) { return PProject("Kotlin", project.rootProject.projectDir, modules, emptyList()) } +/* + Ordering here and below is significant. + Placing 'runtime' configuration dependencies on the top make 'idea' tests to run normally. + ('idea' module has 'intellij-core' as transitive dependency, and we really need to get rid of it.) + */ private val CONFIGURATION_MAPPING = mapOf( + listOf("runtime") to Scope.RUNTIME, listOf("compile") to Scope.COMPILE, - listOf("compileOnly") to Scope.PROVIDED, - listOf("runtime") to Scope.RUNTIME + listOf("compileOnly") to Scope.PROVIDED ) private val TEST_CONFIGURATION_MAPPING = mapOf( + listOf("runtime", "testRuntime") to Scope.RUNTIME, listOf("compile", "testCompile") to Scope.COMPILE, - listOf("compileOnly", "testCompileOnly") to Scope.PROVIDED, - listOf("runtime", "testRuntime") to Scope.RUNTIME + listOf("compileOnly", "testCompileOnly") to Scope.PROVIDED ) private val SOURCE_SET_MAPPING = mapOf( @@ -227,8 +232,7 @@ private fun ParserContext.parseDependencies(project: Project, forTests: Boolean) val configurationMapping = if (forTests) TEST_CONFIGURATION_MAPPING else CONFIGURATION_MAPPING with(project.configurations) { - val moduleRoots = mutableListOf() - val libraryRoots = mutableListOf() + val mainRoots = mutableListOf() val deferredRoots = mutableListOf() fun collectConfigurations(): List> { @@ -255,9 +259,9 @@ private fun ParserContext.parseDependencies(project: Project, forTests: Boolean) if (mappedDependency != null) { val orderRoot = POrderRoot(mappedDependency.main, scope) if (mappedDependency.main is PDependency.Module) { - moduleRoots += orderRoot + mainRoots += orderRoot } else { - libraryRoots += orderRoot + mainRoots += orderRoot } for (deferredDep in mappedDependency.deferred) { @@ -270,9 +274,9 @@ private fun ParserContext.parseDependencies(project: Project, forTests: Boolean) } if (dependency.configuration == "runtimeElements") { - moduleRoots += POrderRoot(PDependency.Module(dependency.moduleName + ".src"), scope) + mainRoots += POrderRoot(PDependency.Module(dependency.moduleName + ".src"), scope) } else if (dependency.configuration == "tests-jar") { - moduleRoots += POrderRoot( + mainRoots += POrderRoot( PDependency.Module(dependency.moduleName + ".test"), scope, isProductionOnTestDependency = true @@ -280,11 +284,11 @@ private fun ParserContext.parseDependencies(project: Project, forTests: Boolean) } else { val classes = dependency.moduleArtifacts.map { it.file } val library = PLibrary(dependency.moduleName, classes) - libraryRoots += POrderRoot(PDependency.ModuleLibrary(library), scope) + mainRoots += POrderRoot(PDependency.ModuleLibrary(library), scope) } } - return removeDuplicates(moduleRoots + libraryRoots + deferredRoots) + return removeDuplicates(mainRoots + deferredRoots) } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ScriptGenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/ScriptGenTest.kt index d67fbde66f6..29031a9741c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ScriptGenTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ScriptGenTest.kt @@ -43,7 +43,7 @@ class ScriptGenTest : CodegenTestCase() { super.setUp() additionalDependencies = System.getenv("PROJECT_CLASSES_DIRS")?.split(File.pathSeparator)?.map { File(it) } - ?: listOf("compiler/build/classes/kotlin/test", "build/compiler/classes/kotlin/test") + ?: listOf("compiler/build/classes/kotlin/test", "build/compiler/classes/kotlin/test", "out/test/compiler.test") .mapNotNull { File(it).canonicalFile.takeIf { it.isDirectory } } .takeIf { it.isNotEmpty() } ?: throw IllegalStateException("Unable to get classes output dirs, set PROJECT_CLASSES_DIRS environment variable") diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index ba0fc4e2776..5c9b07a2f16 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -37,6 +37,8 @@ dependencies { compile(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false } compile("teamcity:markdown") + compileOnly(project(":kotlin-daemon-client")) + compileOnly(intellijCoreDep()) { includeJars("intellij-core") } compileOnly(intellijDep()) { includeJars("annotations", "openapi", "idea", "velocity", "boot", "gson", "log4j", "asm-all", diff --git a/idea/idea-android/build.gradle.kts b/idea/idea-android/build.gradle.kts index a8553170f43..a9672b0edf1 100644 --- a/idea/idea-android/build.gradle.kts +++ b/idea/idea-android/build.gradle.kts @@ -20,6 +20,7 @@ dependencies { compile(androidDxJar()) + compileOnly(project(":kotlin-android-extensions-runtime")) compileOnly(intellijDep()) { includeJars("openapi", "idea", "extensions", "util", "guava", "android-base-common", rootProject = rootProject) } compileOnly(intellijPluginDep("android")) { includeJars("android", "android-common", "sdk-common", "sdklib", "sdk-tools", "layoutlib-api") diff --git a/plugins/allopen/allopen-ide/build.gradle.kts b/plugins/allopen/allopen-ide/build.gradle.kts index 28cbc34ff1a..af5b95b5c03 100644 --- a/plugins/allopen/allopen-ide/build.gradle.kts +++ b/plugins/allopen/allopen-ide/build.gradle.kts @@ -15,7 +15,7 @@ dependencies { compile(project(":idea:idea-jvm")) compile(project(":idea:idea-jps-common")) compile(project(":plugins:annotation-based-compiler-plugins-ide-support")) - compileOnly(intellijDep()) { includeJars("openapi", "idea", "util") } + compileOnly(intellijDep()) { includeJars("openapi", "idea", "util", "extensions") } excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) { includeJars("maven") } } compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", "gradle", rootProject = rootProject) } } diff --git a/plugins/lint/build.gradle.kts b/plugins/lint/build.gradle.kts index cec7465f072..a4e43d1a49c 100644 --- a/plugins/lint/build.gradle.kts +++ b/plugins/lint/build.gradle.kts @@ -12,6 +12,7 @@ dependencies { compile(project(":idea:idea-core")) compile(project(":idea:idea-android")) compile(project(":plugins:uast-kotlin")) + compileOnly(project(":kotlin-android-extensions-runtime")) compileOnly(intellijCoreDep()) { includeJars("intellij-core") } compileOnly(intellijDep()) { includeJars("util", "guava", "openapi", "idea", "asm-all", "annotations", rootProject = rootProject) } compileOnly(intellijPluginDep("android")) { diff --git a/plugins/noarg/noarg-ide/build.gradle.kts b/plugins/noarg/noarg-ide/build.gradle.kts index 6b12effab4d..14b076019e2 100644 --- a/plugins/noarg/noarg-ide/build.gradle.kts +++ b/plugins/noarg/noarg-ide/build.gradle.kts @@ -16,7 +16,7 @@ dependencies { compile(project(":idea")) compile(project(":idea:idea-jps-common")) compile(project(":plugins:annotation-based-compiler-plugins-ide-support")) - compileOnly(intellijDep()) { includeJars("openapi", "idea", "util") } + compileOnly(intellijDep()) { includeJars("openapi", "idea", "util", "extensions") } excludeInAndroidStudio(rootProject) { compileOnly(intellijPluginDep("maven")) { includeJars("maven") } } compileOnly(intellijPluginDep("gradle")) { includeJars("gradle-tooling-api", "gradle", rootProject = rootProject) } }