From a703fc0f176318562f418fe8b5c6305a364ffa52 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 20 Jul 2023 23:49:58 +0900 Subject: [PATCH] [Pill] Remove obsolete IDE plugin artifact creation --- plugins/pill/pill-importer/build.gradle.kts | 3 +- .../src/JpsCompatiblePluginTasks.kt | 28 +----- .../pill-importer/src/PillExtensionMirror.kt | 4 +- .../pill/pill-importer/src/PillImporter.kt | 4 +- .../src/artifact/ArtifactDependencyMapper.kt | 12 --- .../src/artifact/ArtifactElement.kt | 72 -------------- .../src/artifact/ArtifactGenerator.kt | 97 ------------------- .../pill-importer/src/artifact/PArtifact.kt | 23 ----- 8 files changed, 6 insertions(+), 237 deletions(-) delete mode 100644 plugins/pill/pill-importer/src/artifact/ArtifactDependencyMapper.kt delete mode 100644 plugins/pill/pill-importer/src/artifact/ArtifactElement.kt delete mode 100644 plugins/pill/pill-importer/src/artifact/ArtifactGenerator.kt delete mode 100644 plugins/pill/pill-importer/src/artifact/PArtifact.kt diff --git a/plugins/pill/pill-importer/build.gradle.kts b/plugins/pill/pill-importer/build.gradle.kts index 539c3b3c26c..4b2f61dc1fc 100644 --- a/plugins/pill/pill-importer/build.gradle.kts +++ b/plugins/pill/pill-importer/build.gradle.kts @@ -35,9 +35,8 @@ fun runPillTask(taskName: String) { val platformDir = rootProject.ideaHomePathForTests() val resourcesDir = File(project.projectDir, "resources") - val isIdePluginAttached = project.rootProject.intellijSdkVersionForIde() != null - runMethod.invoke(null, project.rootProject, taskName, platformDir, resourcesDir, isIdePluginAttached) + runMethod.invoke(null, project.rootProject, taskName, platformDir, resourcesDir) } val jar: Jar by tasks diff --git a/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt b/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt index b242b921f27..ce537724777 100644 --- a/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt +++ b/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt @@ -16,8 +16,6 @@ import org.jdom2.Verifier import org.jdom2.input.SAXBuilder import org.jdom2.output.Format import org.jdom2.output.XMLOutputter -import org.jetbrains.kotlin.pill.artifact.ArtifactDependencyMapper -import org.jetbrains.kotlin.pill.artifact.ArtifactGenerator import org.jetbrains.kotlin.pill.model.PDependency import org.jetbrains.kotlin.pill.model.PLibrary import org.jetbrains.kotlin.pill.model.POrderRoot @@ -31,8 +29,7 @@ const val EMBEDDED_CONFIGURATION_NAME = "embedded" class JpsCompatiblePluginTasks( private val rootProject: Project, private val platformDir: File, - private val resourcesDir: File, - private val isIdePluginAttached: Boolean + private val resourcesDir: File ) { companion object { private val DIST_LIBRARIES = listOf( @@ -118,29 +115,6 @@ class JpsCompatiblePluginTasks( removeJpsAndPillRunConfigurations() removeArtifactConfigurations() - if (isIdePluginAttached && variant.includes.contains(PillExtensionMirror.Variant.BASE)) { - val artifactDependencyMapper = object : ArtifactDependencyMapper { - override fun map(dependency: PDependency): List { - val result = mutableListOf() - - for (mappedDependency in jpsProject.mapDependency(dependency, dependencyMappers)) { - result += mappedDependency - - if (mappedDependency is PDependency.Module) { - val module = jpsProject.modules.find { it.name == mappedDependency.name } - if (module != null) { - result += module.embeddedDependencies - } - } - } - - return result - } - } - - ArtifactGenerator(artifactDependencyMapper).generateKotlinPluginArtifact(rootProject).write() - } - copyRunConfigurations() setOptionsForDefaultJunitRunConfiguration(rootProject) diff --git a/plugins/pill/pill-importer/src/PillExtensionMirror.kt b/plugins/pill/pill-importer/src/PillExtensionMirror.kt index ce91b96f4e6..5db1cd2b840 100644 --- a/plugins/pill/pill-importer/src/PillExtensionMirror.kt +++ b/plugins/pill/pill-importer/src/PillExtensionMirror.kt @@ -12,8 +12,8 @@ open class PillExtensionMirror(variant: String?, val excludedDirs: List) { val variant = if (variant == null) null else Variant.valueOf(variant) enum class Variant(includesFactory: () -> Set) { - BASE({ setOf(BASE) }), // Includes compiler and IDE (default) - FULL({ setOf(BASE, FULL) }); // Includes compiler, IDE and Gradle plugin + BASE({ setOf(BASE) }), // Includes only compiler (default) + FULL({ setOf(BASE, FULL) }); // Includes compiler and Gradle plugin val includes by lazy { includesFactory() } } diff --git a/plugins/pill/pill-importer/src/PillImporter.kt b/plugins/pill/pill-importer/src/PillImporter.kt index f63daaf6cca..33d6aab9693 100644 --- a/plugins/pill/pill-importer/src/PillImporter.kt +++ b/plugins/pill/pill-importer/src/PillImporter.kt @@ -16,8 +16,8 @@ object PillImporter { ) @JvmStatic - fun run(rootProject: Project, taskName: String, platformDir: File, resourcesDir: File, isIdePluginAttached: Boolean) { - val tasks = JpsCompatiblePluginTasks(rootProject, platformDir, resourcesDir, isIdePluginAttached) + fun run(rootProject: Project, taskName: String, platformDir: File, resourcesDir: File) { + val tasks = JpsCompatiblePluginTasks(rootProject, platformDir, resourcesDir) val task = TASKS[taskName] ?: error("Unknown task $taskName, available tasks: " + TASKS.keys.joinToString()) task(tasks) } diff --git a/plugins/pill/pill-importer/src/artifact/ArtifactDependencyMapper.kt b/plugins/pill/pill-importer/src/artifact/ArtifactDependencyMapper.kt deleted file mode 100644 index ed1a322aab5..00000000000 --- a/plugins/pill/pill-importer/src/artifact/ArtifactDependencyMapper.kt +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.pill.artifact - -import org.jetbrains.kotlin.pill.model.PDependency - -interface ArtifactDependencyMapper { - fun map(dependency: PDependency): List -} \ No newline at end of file diff --git a/plugins/pill/pill-importer/src/artifact/ArtifactElement.kt b/plugins/pill/pill-importer/src/artifact/ArtifactElement.kt deleted file mode 100644 index d532e30b983..00000000000 --- a/plugins/pill/pill-importer/src/artifact/ArtifactElement.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.pill.artifact - -import org.jetbrains.kotlin.pill.util.PathContext -import org.jetbrains.kotlin.pill.util.XmlNode -import org.jetbrains.kotlin.pill.util.xml -import java.io.File - -sealed class ArtifactElement { - private val myChildren = mutableListOf() - private val children get() = myChildren - - fun add(child: ArtifactElement) { - myChildren += child - } - - fun add(children: List) { - myChildren += children - } - - abstract fun render(context: PathContext): XmlNode - - fun renderRecursively(context: PathContext): XmlNode { - return render(context).apply { - children.forEach { add(it.renderRecursively(context)) } - } - } - - class Root : ArtifactElement() { - override fun render(context: PathContext) = xml("root", "id" to "root") - } - - data class Directory(val name: String) : ArtifactElement() { - override fun render(context: PathContext) = xml("element", "id" to "directory", "name" to name) - } - - data class Archive(val name: String) : ArtifactElement() { - override fun render(context: PathContext) = xml("element", "id" to "archive", "name" to name) - } - - data class ModuleOutput(val moduleName: String) : ArtifactElement() { - override fun render(context: PathContext) = xml("element", "id" to "module-output", "name" to moduleName) - } - - data class FileCopy(val source: File, val outputFileName: String? = null) : ArtifactElement() { - override fun render(context: PathContext): XmlNode { - val args = mutableListOf("id" to "file-copy", "path" to context(source)) - if (outputFileName != null) { - args += "output-file-name" to outputFileName - } - - return xml("element", *args.toTypedArray()) - } - } - - data class DirectoryCopy(val source: File) : ArtifactElement() { - override fun render(context: PathContext) = xml("element", "id" to "dir-copy", "path" to context(source)) - } - - data class ProjectLibrary(val name: String) : ArtifactElement() { - override fun render(context: PathContext) = xml("element", "id" to "library", "level" to "project", "name" to name) - } - - data class ExtractedDirectory(val archive: File, val pathInJar: String = "/") : ArtifactElement() { - override fun render(context: PathContext) = - xml("element", "id" to "extracted-dir", "path" to context(archive), "path-in-jar" to pathInJar) - } -} \ No newline at end of file diff --git a/plugins/pill/pill-importer/src/artifact/ArtifactGenerator.kt b/plugins/pill/pill-importer/src/artifact/ArtifactGenerator.kt deleted file mode 100644 index d7a4b441863..00000000000 --- a/plugins/pill/pill-importer/src/artifact/ArtifactGenerator.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.pill.artifact - -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.kotlin.dsl.extra -import org.jetbrains.kotlin.pill.* -import org.jetbrains.kotlin.pill.model.PDependency -import org.jetbrains.kotlin.pill.model.PLibrary -import org.jetbrains.kotlin.pill.util.ProjectContext -import java.io.File - -class ArtifactGenerator(private val dependencyMapper: ArtifactDependencyMapper) { - fun generateKotlinPluginArtifact(rootProject: Project): PFile { - val root = ArtifactElement.Root() - - fun Project.getProject(name: String) = findProject(name) ?: error("Cannot find project $name") - - val prepareIdeaPluginProject = rootProject.getProject(":prepare:idea-plugin") - - root.add(ArtifactElement.Directory("kotlinc").apply { - val kotlincDirectory = rootProject.extra["distKotlinHomeDir"].toString() - add(ArtifactElement.DirectoryCopy(File(kotlincDirectory))) - }) - - root.add(ArtifactElement.Directory("lib").apply { - val librariesConfiguration = prepareIdeaPluginProject.configurations.getByName("libraries") - add(getArtifactElements(librariesConfiguration, false)) - - add(ArtifactElement.Directory("jps").apply { - val prepareJpsPluginProject = rootProject.getProject(":kotlin-jps-plugin") - add(ArtifactElement.Archive(prepareJpsPluginProject.name + ".jar").apply { - val jpsPluginConfiguration = prepareJpsPluginProject.configurations.getByName(EMBEDDED_CONFIGURATION_NAME) - add(getArtifactElements(jpsPluginConfiguration, true)) - }) - }) - - add(ArtifactElement.Archive("kotlin-plugin.jar").apply { - add(ArtifactElement.FileCopy(File(rootProject.projectDir, "resources/kotlinManifest.properties"))) - - val embeddedConfiguration = prepareIdeaPluginProject.configurations.getByName(EMBEDDED_CONFIGURATION_NAME) - add(getArtifactElements(embeddedConfiguration, true)) - }) - }) - - val artifact = PArtifact("KotlinPlugin", File(rootProject.projectDir, "out/artifacts/Kotlin"), root) - return PFile( - File(rootProject.projectDir, ".idea/artifacts/${artifact.artifactName}.xml"), - artifact.render(ProjectContext(rootProject)) - ) - } - - private fun getArtifactElements(configuration: Configuration, extractDependencies: Boolean): List { - val artifacts = mutableListOf() - - fun process(dependency: PDependency) { - when (dependency) { - is PDependency.Module -> { - val moduleOutput = ArtifactElement.ModuleOutput(dependency.name) - - if (extractDependencies) { - artifacts += moduleOutput - } else { - artifacts += ArtifactElement.Archive(dependency.name + ".jar").apply { - add(moduleOutput) - } - } - } - is PDependency.Library -> artifacts += ArtifactElement.ProjectLibrary(dependency.name) - is PDependency.ModuleLibrary -> { - val files = dependency.library.classes - if (extractDependencies) { - files.mapTo(artifacts) { ArtifactElement.ExtractedDirectory(it) } - } else { - files.mapTo(artifacts) { ArtifactElement.FileCopy(it) } - } - } - } - } - - parseDependencies(configuration).forEach(::process) - return artifacts - } - - private fun parseDependencies(configuration: Configuration): List { - val dependencies = mutableListOf() - for (file in configuration.resolve()) { - val library = PLibrary(file.name, listOf(file)) - dependencies += dependencyMapper.map(PDependency.ModuleLibrary(library)) - } - return dependencies - } -} \ No newline at end of file diff --git a/plugins/pill/pill-importer/src/artifact/PArtifact.kt b/plugins/pill/pill-importer/src/artifact/PArtifact.kt deleted file mode 100644 index 1bb740de337..00000000000 --- a/plugins/pill/pill-importer/src/artifact/PArtifact.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.pill.artifact - -import org.jetbrains.kotlin.pill.artifact.ArtifactElement.* -import org.jetbrains.kotlin.pill.util.PathContext -import org.jetbrains.kotlin.pill.util.xml -import java.io.File - -class PArtifact(val artifactName: String, private val outputDir: File, private val contents: Root) { - fun render(context: PathContext) = xml("component", "name" to "ArtifactManager") { - xml("artifact", "name" to artifactName) { - xml("output-path") { - raw(context(outputDir)) - } - - add(contents.renderRecursively(context)) - } - } -} \ No newline at end of file