[Pill] Remove obsolete IDE plugin artifact creation

This commit is contained in:
Yan Zhulanow
2023-07-20 23:49:58 +09:00
committed by Space Team
parent 680db7c317
commit a703fc0f17
8 changed files with 6 additions and 237 deletions
+1 -2
View File
@@ -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
@@ -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<PDependency> {
val result = mutableListOf<PDependency>()
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)
@@ -12,8 +12,8 @@ open class PillExtensionMirror(variant: String?, val excludedDirs: List<File>) {
val variant = if (variant == null) null else Variant.valueOf(variant)
enum class Variant(includesFactory: () -> Set<Variant>) {
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() }
}
@@ -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)
}
@@ -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<PDependency>
}
@@ -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<ArtifactElement>()
private val children get() = myChildren
fun add(child: ArtifactElement) {
myChildren += child
}
fun add(children: List<ArtifactElement>) {
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)
}
}
@@ -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<ArtifactElement> {
val artifacts = mutableListOf<ArtifactElement>()
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<PDependency> {
val dependencies = mutableListOf<PDependency>()
for (file in configuration.resolve()) {
val library = PLibrary(file.name, listOf(file))
dependencies += dependencyMapper.map(PDependency.ModuleLibrary(library))
}
return dependencies
}
}
@@ -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))
}
}
}