Pill, Small: Pass libraries to 'parse()' directly

This commit is contained in:
Yan Zhulanow
2018-02-20 22:57:51 +03:00
parent 07ede20dc5
commit 3da479c1d5
3 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -78,7 +78,7 @@ data class PLibrary(
} }
} }
fun parse(project: Project, context: ParserContext): PProject = with (context) { fun parse(project: Project, libraries: List<PLibrary>, context: ParserContext): PProject = with (context) {
if (project != project.rootProject) { if (project != project.rootProject) {
error("$project is not a root project") 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) } .filter { it.plugins.hasPlugin(JpsCompatiblePlugin::class.java) }
.flatMap { parseModules(it) } .flatMap { parseModules(it) }
return PProject("Kotlin", project.projectDir, modules, emptyList()) return PProject("Kotlin", project.projectDir, modules, libraries)
} }
/* /*
+5 -5
View File
@@ -42,9 +42,9 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
DependencyMapper("org.jetbrains.kotlin", "compiler", "runtimeElements") { null } DependencyMapper("org.jetbrains.kotlin", "compiler", "runtimeElements") { null }
) )
fun getProjectLibraries(project: PProject): List<PLibrary> { fun getProjectLibraries(project: Project): List<PLibrary> {
fun distJar(name: String) = File(project.rootDirectory, "dist/kotlinc/lib/$name.jar") fun distJar(name: String) = File(project.projectDir, "dist/kotlinc/lib/$name.jar")
fun projectFile(path: String) = File(project.rootDirectory, path) fun projectFile(path: String) = File(project.projectDir, path)
return listOf( return listOf(
PLibrary( PLibrary(
@@ -116,12 +116,12 @@ class JpsCompatibleRootPlugin : Plugin<Project> {
private fun pill(project: Project) { private fun pill(project: Project) {
initEnvironment(project) initEnvironment(project)
val jpsProject = parse(project, ParserContext(dependencyMappers)) val jpsProject = parse(project, getProjectLibraries(project), ParserContext(dependencyMappers))
.mapLibraries(this::attachPlatformSources, this::attachAsmSources) .mapLibraries(this::attachPlatformSources, this::attachAsmSources)
generateKotlinPluginArtifactFile(project).write() generateKotlinPluginArtifactFile(project).write()
val files = render(jpsProject, getProjectLibraries(jpsProject)) val files = render(jpsProject)
removeExistingIdeaLibrariesAndModules() removeExistingIdeaLibrariesAndModules()
removeJpsRunConfigurations() removeJpsRunConfigurations()
+2 -2
View File
@@ -12,12 +12,12 @@ class PFile(val path: File, val text: String) {
fun PFile(path: File, xml: xml) = PFile(path, xml.toString()) fun PFile(path: File, xml: xml) = PFile(path, xml.toString())
fun render(project: PProject, extraLibraries: List<PLibrary> = emptyList()): List<PFile> { fun render(project: PProject): List<PFile> {
val files = mutableListOf<PFile>() val files = mutableListOf<PFile>()
files += renderModulesFile(project) files += renderModulesFile(project)
project.modules.forEach { files += renderModule(project, it) } project.modules.forEach { files += renderModule(project, it) }
(project.libraries + extraLibraries).forEach { files += renderLibrary(project, it) } project.libraries.forEach { files += renderLibrary(project, it) }
return files return files
} }