From 83655b4ba31bf4f4f5dd98f687fe1a2c7285a567 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 8 Apr 2024 18:23:46 +0200 Subject: [PATCH] use pluginAuto for rest of Community plugins GitOrigin-RevId: d7d2e762fb10d5971d70f71c7271620326621f32 --- .../build/CommunityRepositoryModules.kt | 41 ++++++------------- .../build/PluginBundlingRestrictions.kt | 4 +- .../intellij/build/impl/PluginLayout.kt | 31 ++++++-------- 3 files changed, 28 insertions(+), 48 deletions(-) diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/CommunityRepositoryModules.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/CommunityRepositoryModules.kt index 4c8104eba55a..74937f94d4dc 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/CommunityRepositoryModules.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/CommunityRepositoryModules.kt @@ -57,13 +57,13 @@ object CommunityRepositoryModules { spec.withModule("intellij.java.guiForms.jps", "jps/java-guiForms-jps.jar") }, KotlinPluginBuilder.kotlinPlugin(KotlinPluginBuilder.KotlinUltimateSources.WITH_COMMUNITY_MODULES), - plugin("intellij.vcs.git") { spec -> + pluginAuto(listOf("intellij.vcs.git")) { spec -> spec.withModule("intellij.vcs.git.rt", "git4idea-rt.jar") }, - plugin("intellij.xpath") { spec -> + pluginAuto(listOf("intellij.xpath")) { spec -> spec.withModule("intellij.xpath.rt", "rt/xslt-rt.jar") }, - plugin("intellij.platform.langInjection") { spec -> + pluginAuto(listOf("intellij.platform.langInjection")) { spec -> spec.withModule("intellij.java.langInjection", "IntelliLang.jar") spec.withModule("intellij.xml.langInjection", "IntelliLang.jar") spec.withModule("intellij.java.langInjection.jps") @@ -77,7 +77,7 @@ object CommunityRepositoryModules { spec.withProjectLibrary("XmlRPC") spec.withProjectLibrary("jsonpath") }, - plugin("intellij.xslt.debugger") { spec -> + pluginAuto(listOf("intellij.xslt.debugger")) { spec -> spec.withModule("intellij.xslt.debugger.rt", "xslt-debugger-rt.jar") spec.withModule("intellij.xslt.debugger.impl.rt", "rt/xslt-debugger-impl-rt.jar") spec.withModuleLibrary("Saxon-6.5.5", "intellij.xslt.debugger.impl.rt", "rt/saxon.jar") @@ -131,7 +131,7 @@ object CommunityRepositoryModules { copyDir(mavenDist, targetLib.resolve("maven3")) } }, - plugin(listOf( + pluginAuto(listOf( "intellij.gradle", "intellij.gradle.common", "intellij.gradle.toolingProxy", @@ -171,22 +171,10 @@ object CommunityRepositoryModules { spec.withProjectLibrary("TestNG") }, pluginAuto(listOf("intellij.dev", "intellij.platform.statistics.devkit")), - plugin("intellij.devkit") { spec -> - spec.withModule("intellij.devkit.core") - spec.withModule("intellij.devkit.git") - spec.withModule("intellij.devkit.themes") - spec.withModule("intellij.devkit.gradle") - spec.withModule("intellij.devkit.i18n") - spec.withModule("intellij.devkit.images") - spec.withModule("intellij.devkit.intelliLang") - spec.withModule("intellij.devkit.uiDesigner") - spec.withModule("intellij.devkit.workspaceModel") - spec.withModule("intellij.kotlin.devkit") + pluginAuto(listOf("intellij.devkit")) { spec -> spec.withModule("intellij.devkit.jps") spec.withModule("intellij.devkit.runtimeModuleRepository.jps") - spec.withProjectLibrary("workspace-model-codegen") - spec.bundlingRestrictions.includeInDistribution = PluginDistribution.NOT_FOR_PUBLIC_BUILDS }, pluginAuto(listOf("intellij.eclipse")) { spec -> @@ -209,19 +197,19 @@ object CommunityRepositoryModules { spec.withModule("intellij.terminal.sh") spec.withResource("resources/shell-integrations", "shell-integrations") }, - plugin("intellij.emojipicker") { spec -> + pluginAuto("intellij.emojipicker") { spec -> spec.bundlingRestrictions.supportedOs = persistentListOf(OsFamily.LINUX) }, - plugin("intellij.textmate") { spec -> + pluginAuto("intellij.textmate") { spec -> spec.withModule("intellij.textmate.core") spec.withResource("lib/bundles", "lib/bundles") }, PythonCommunityPluginModules.pythonCommunityPluginLayout(), androidDesignPlugin(), - plugin("intellij.completionMlRankingModels") { spec -> + pluginAuto(listOf("intellij.completionMlRankingModels")) { spec -> spec.bundlingRestrictions.includeInDistribution = PluginDistribution.NOT_FOR_RELEASE }, - plugin("intellij.statsCollector") { spec -> + pluginAuto(listOf("intellij.statsCollector")) { spec -> spec.bundlingRestrictions.includeInDistribution = PluginDistribution.NOT_FOR_RELEASE }, pluginAuto(listOf("intellij.lombok", "intellij.lombok.generated")), @@ -241,16 +229,16 @@ object CommunityRepositoryModules { )) val CONTRIB_REPOSITORY_PLUGINS: List = java.util.List.of( - plugin("intellij.errorProne") { spec -> + pluginAuto("intellij.errorProne") { spec -> spec.withModule("intellij.errorProne.jps", "jps/errorProne-jps.jar") }, - plugin("intellij.cucumber.java") { spec -> + pluginAuto("intellij.cucumber.java") { spec -> spec.withModule("intellij.cucumber.jvmFormatter", "cucumber-jvmFormatter.jar") spec.withModule("intellij.cucumber.jvmFormatter3", "cucumber-jvmFormatter3.jar") spec.withModule("intellij.cucumber.jvmFormatter4", "cucumber-jvmFormatter4.jar") spec.withModule("intellij.cucumber.jvmFormatter5", "cucumber-jvmFormatter5.jar") }, - plugin("intellij.serial.monitor") { spec -> + pluginAuto("intellij.serial.monitor") { spec -> spec.withProjectLibrary("io.github.java.native.jssc", LibraryPackMode.STANDALONE_SEPARATE) }, ) @@ -766,9 +754,6 @@ object CommunityRepositoryModules { } } - - @JvmStatic - @JvmOverloads fun groovyPlugin(additionalModules: List = emptyList(), addition: ((PluginLayout.PluginLayoutSpec) -> Unit)? = null): PluginLayout { return plugin("intellij.groovy") { spec -> spec.directoryName = "Groovy" diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/PluginBundlingRestrictions.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/PluginBundlingRestrictions.kt index 69ad0c8e2ddd..d0f8ef18ee40 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/PluginBundlingRestrictions.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/PluginBundlingRestrictions.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.intellij.build import kotlinx.collections.immutable.PersistentList @@ -10,7 +10,7 @@ import java.util.Objects * * @see org.jetbrains.intellij.build.impl.PluginLayout.PluginLayoutSpec#getBundlingRestrictions() */ -class PluginBundlingRestrictions private constructor( +class PluginBundlingRestrictions( /** * Change this value if the plugin works on some OS only and therefore don't need to be bundled with distributions for other OS. */ diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PluginLayout.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PluginLayout.kt index 577a511815d9..d0470d10d8a3 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PluginLayout.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/PluginLayout.kt @@ -113,11 +113,14 @@ class PluginLayout private constructor( return layout } - @JvmStatic - fun plugin(moduleNames: List, body: (SimplePluginLayoutSpec) -> Unit): PluginLayout { - val layout = PluginLayout(mainModule = moduleNames.first()) + fun pluginAuto(moduleName: String, body: (SimplePluginLayoutSpec) -> Unit): PluginLayout = pluginAuto(listOf(moduleName), body) + + fun pluginAuto(moduleNames: List, body: (SimplePluginLayoutSpec) -> Unit): PluginLayout { + val layout = PluginLayout(mainModule = moduleNames.first(), auto = true) layout.withModules(moduleNames) - body(SimplePluginLayoutSpec(layout)) + val spec = SimplePluginLayoutSpec(layout) + body(spec) + layout.bundlingRestrictions = spec.bundlingRestrictions.build() return layout } @@ -137,13 +140,6 @@ class PluginLayout private constructor( return layout } - fun pluginAuto(moduleNames: List, body: (SimplePluginLayoutSpec) -> Unit): PluginLayout { - val layout = PluginLayout(mainModule = moduleNames.first(), auto = true) - layout.withModules(moduleNames) - body(SimplePluginLayoutSpec(layout)) - return layout - } - fun plugin(mainModule: String): PluginLayout { val layout = PluginLayout(mainModule = mainModule) layout.withModule(mainModule) @@ -167,6 +163,11 @@ class PluginLayout private constructor( } sealed class PluginLayoutBuilder(@JvmField protected val layout: PluginLayout) : BaseLayoutSpec(layout) { + /** + * Returns [PluginBundlingRestrictions] instance which can be used to exclude the plugin from some distributions. + */ + val bundlingRestrictions: PluginBundlingRestrictions.Builder = PluginBundlingRestrictions.Builder() + /** * @param resourcePath path to resource file or directory relative to the plugin's main module content root * @param relativeOutputPath target path relative to the plugin root directory @@ -194,8 +195,7 @@ class PluginLayout private constructor( } } - @Experimental - class SimplePluginLayoutSpec(layout: PluginLayout) : PluginLayoutBuilder(layout) + class SimplePluginLayoutSpec internal constructor(layout: PluginLayout) : PluginLayoutBuilder(layout) // as a builder for PluginLayout, that ideally should be immutable class PluginLayoutSpec(layout: PluginLayout) : PluginLayoutBuilder(layout) { @@ -216,11 +216,6 @@ class PluginLayout private constructor( val mainModule get() = layout.mainModule - /** - * Returns [PluginBundlingRestrictions] instance which can be used to exclude the plugin from some distributions. - */ - val bundlingRestrictions: PluginBundlingRestrictions.Builder = PluginBundlingRestrictions.Builder() - var mainJarName: String get() = layout.mainJarName /**