From 3da479c1d5b374011e838bc6428e2ceba475e8ee Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 20 Feb 2018 22:57:51 +0300 Subject: [PATCH] Pill, Small: Pass libraries to 'parse()' directly --- buildSrc/src/main/kotlin/pill/parser.kt | 4 ++-- buildSrc/src/main/kotlin/pill/plugin.kt | 10 +++++----- buildSrc/src/main/kotlin/pill/render.kt | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/kotlin/pill/parser.kt b/buildSrc/src/main/kotlin/pill/parser.kt index 6ed3046bf19..1399890bd1f 100644 --- a/buildSrc/src/main/kotlin/pill/parser.kt +++ b/buildSrc/src/main/kotlin/pill/parser.kt @@ -78,7 +78,7 @@ data class PLibrary( } } -fun parse(project: Project, context: ParserContext): PProject = with (context) { +fun parse(project: Project, libraries: List, context: ParserContext): PProject = with (context) { if (project != project.rootProject) { error("$project is not a root project") } @@ -87,7 +87,7 @@ fun parse(project: Project, context: ParserContext): PProject = with (context) { .filter { it.plugins.hasPlugin(JpsCompatiblePlugin::class.java) } .flatMap { parseModules(it) } - return PProject("Kotlin", project.projectDir, modules, emptyList()) + return PProject("Kotlin", project.projectDir, modules, libraries) } /* diff --git a/buildSrc/src/main/kotlin/pill/plugin.kt b/buildSrc/src/main/kotlin/pill/plugin.kt index 2291a9d5a56..7c92d5e6a56 100644 --- a/buildSrc/src/main/kotlin/pill/plugin.kt +++ b/buildSrc/src/main/kotlin/pill/plugin.kt @@ -42,9 +42,9 @@ class JpsCompatibleRootPlugin : Plugin { DependencyMapper("org.jetbrains.kotlin", "compiler", "runtimeElements") { null } ) - fun getProjectLibraries(project: PProject): List { - fun distJar(name: String) = File(project.rootDirectory, "dist/kotlinc/lib/$name.jar") - fun projectFile(path: String) = File(project.rootDirectory, path) + fun getProjectLibraries(project: Project): List { + fun distJar(name: String) = File(project.projectDir, "dist/kotlinc/lib/$name.jar") + fun projectFile(path: String) = File(project.projectDir, path) return listOf( PLibrary( @@ -116,12 +116,12 @@ class JpsCompatibleRootPlugin : Plugin { private fun pill(project: Project) { initEnvironment(project) - val jpsProject = parse(project, ParserContext(dependencyMappers)) + val jpsProject = parse(project, getProjectLibraries(project), ParserContext(dependencyMappers)) .mapLibraries(this::attachPlatformSources, this::attachAsmSources) generateKotlinPluginArtifactFile(project).write() - val files = render(jpsProject, getProjectLibraries(jpsProject)) + val files = render(jpsProject) removeExistingIdeaLibrariesAndModules() removeJpsRunConfigurations() diff --git a/buildSrc/src/main/kotlin/pill/render.kt b/buildSrc/src/main/kotlin/pill/render.kt index 10a50e49058..15422798086 100644 --- a/buildSrc/src/main/kotlin/pill/render.kt +++ b/buildSrc/src/main/kotlin/pill/render.kt @@ -12,12 +12,12 @@ class PFile(val path: File, val text: String) { fun PFile(path: File, xml: xml) = PFile(path, xml.toString()) -fun render(project: PProject, extraLibraries: List = emptyList()): List { +fun render(project: PProject): List { val files = mutableListOf() files += renderModulesFile(project) project.modules.forEach { files += renderModule(project, it) } - (project.libraries + extraLibraries).forEach { files += renderLibrary(project, it) } + project.libraries.forEach { files += renderLibrary(project, it) } return files }