mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
build scripts: replace 'version' String by 'versionEvaluator' function in PluginLayout
This way we can have statically defined PluginLayout even if the plugin uses non-standard versioning scheme, and it allows us to reuse PluginLayout for such plugins in different IDEs.
This commit is contained in:
+1
-1
@@ -286,7 +286,7 @@ class DistributionJARsBuilder {
|
||||
}
|
||||
|
||||
private String getPluginVersion(PluginLayout plugin) {
|
||||
return plugin.version != null ? plugin.version : buildContext.buildNumber
|
||||
return plugin.versionEvaluator.apply(buildContext)
|
||||
}
|
||||
|
||||
private List<PluginLayout> getPluginsByModules(Collection<String> modules) {
|
||||
|
||||
+17
-4
@@ -16,6 +16,9 @@
|
||||
package org.jetbrains.intellij.build.impl
|
||||
|
||||
import com.intellij.openapi.util.MultiValuesMap
|
||||
import org.jetbrains.intellij.build.BuildContext
|
||||
|
||||
import java.util.function.Function
|
||||
|
||||
/**
|
||||
* Described layout of a plugin in the product distribution
|
||||
@@ -27,7 +30,7 @@ class PluginLayout extends BaseLayout {
|
||||
String directoryName
|
||||
final Set<String> optionalModules = new LinkedHashSet<>()
|
||||
private boolean doNotCreateSeparateJarForLocalizableResources
|
||||
String version
|
||||
Function<BuildContext, String> versionEvaluator = { BuildContext context -> context.buildNumber } as Function<BuildContext, String>
|
||||
|
||||
private PluginLayout(String mainModule) {
|
||||
this.mainModule = mainModule
|
||||
@@ -49,7 +52,9 @@ class PluginLayout extends BaseLayout {
|
||||
body.delegate = spec
|
||||
body()
|
||||
layout.directoryName = spec.directoryName
|
||||
layout.version = spec.version
|
||||
if (spec.version != null) {
|
||||
layout.versionEvaluator = { BuildContext context -> spec.version } as Function<BuildContext, String>
|
||||
}
|
||||
spec.withModule(mainModuleName, spec.mainJarName)
|
||||
if (layout.doNotCreateSeparateJarForLocalizableResources) {
|
||||
layout.modulesWithLocalizableResourcesInCommonJar.clear()
|
||||
@@ -84,9 +89,9 @@ class PluginLayout extends BaseLayout {
|
||||
* <strong>Don't set this property for new plugins</strong>; it is temporary added to keep layout of old plugins unchanged.
|
||||
*/
|
||||
String mainJarName
|
||||
|
||||
/**
|
||||
* Version of the plugin if it differs from the global build number.
|
||||
* <strong>Don't set this property for new plugins</strong>; it is temporary added to keep versioning scheme for some old plugins.
|
||||
* @deprecated use {@link #withCustomVersion(java.util.function.Function)} instead
|
||||
*/
|
||||
String version
|
||||
|
||||
@@ -134,6 +139,14 @@ class PluginLayout extends BaseLayout {
|
||||
withModule(moduleName, "jps/${moduleName}.jar")
|
||||
}
|
||||
|
||||
/**
|
||||
* By default version of a plugin is equal to the version of the IDE it's built with. This method allows to specify custom version evaluator.
|
||||
* <strong>Don't use this for new plugins</strong>; it is temporary added to keep versioning scheme for some old plugins.
|
||||
*/
|
||||
void withCustomVersion(Function<BuildContext, String> versionEvaluator) {
|
||||
layout.versionEvaluator = versionEvaluator
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not create 'resources_en.jar' and pack all resources into corresponding module JARs.
|
||||
* <strong>Do not use this for new plugins, this method is temporary added to keep layout of old plugins</strong>.
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class PythonCommunityPluginBuilder {
|
||||
def pluginBuildNumber = System.getProperty("build.number", "SNAPSHOT")
|
||||
def options = new BuildOptions(targetOS: BuildOptions.OS_NONE, buildNumber: pluginBuildNumber, outputRootPath: "$home/out/pycharmCE")
|
||||
def buildContext = BuildContext.createContext(binding.ant, binding.projectBuilder, binding.project, binding.global,
|
||||
home, home, new PythonCommunityPluginProperties(pluginBuildNumber),
|
||||
home, home, new PythonCommunityPluginProperties(),
|
||||
ProprietaryBuildTools.DUMMY, options)
|
||||
def buildTasks = BuildTasks.create(buildContext)
|
||||
buildTasks.buildDistributions()
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.intellij.build.CommunityRepositoryModules
|
||||
* @author vlan
|
||||
*/
|
||||
class PythonCommunityPluginProperties extends PythonPluginPropertiesBase {
|
||||
PythonCommunityPluginProperties(String pluginVersion) {
|
||||
PythonCommunityPluginProperties() {
|
||||
super()
|
||||
productCode = "PC"
|
||||
platformPrefix = "PyCharmCore"
|
||||
@@ -29,7 +29,7 @@ class PythonCommunityPluginProperties extends PythonPluginPropertiesBase {
|
||||
productLayout.pluginModulesToPublish = [pythonCommunityPluginModule]
|
||||
|
||||
productLayout.allNonTrivialPlugins = CommunityRepositoryModules.COMMUNITY_REPOSITORY_PLUGINS + [
|
||||
pythonCommunityPluginLayout(pluginVersion)
|
||||
pythonCommunityPluginLayout()
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.intellij.build.pycharm
|
||||
|
||||
import org.jetbrains.intellij.build.ApplicationInfoProperties
|
||||
import org.jetbrains.intellij.build.BuildContext
|
||||
import org.jetbrains.intellij.build.LinuxDistributionCustomizer
|
||||
import org.jetbrains.intellij.build.MacDistributionCustomizer
|
||||
import org.jetbrains.intellij.build.WindowsDistributionCustomizer
|
||||
@@ -44,13 +45,13 @@ abstract class PythonPluginPropertiesBase extends PyCharmPropertiesBase {
|
||||
super()
|
||||
}
|
||||
|
||||
PluginLayout pythonCommunityPluginLayout(String pluginVersion, @DelegatesTo(PluginLayout.PluginLayoutSpec) Closure body = {}) {
|
||||
PluginLayout pythonCommunityPluginLayout(@DelegatesTo(PluginLayout.PluginLayoutSpec) Closure body = {}) {
|
||||
def pluginXmlModules = [
|
||||
"IntelliLang-python",
|
||||
"ipnb",
|
||||
]
|
||||
pythonPlugin(pythonCommunityPluginModule, "python-ce", "python-community-plugin-build-patches",
|
||||
communityModules, pluginVersion) {
|
||||
communityModules) {
|
||||
withProjectLibrary("markdown4j-2.2") // Required for ipnb
|
||||
pluginXmlModules.each { module ->
|
||||
excludeFromModule(module, "META-INF/plugin.xml")
|
||||
@@ -62,16 +63,20 @@ abstract class PythonPluginPropertiesBase extends PyCharmPropertiesBase {
|
||||
}
|
||||
|
||||
static PluginLayout pythonPlugin(String mainModuleName, String name, String buildPatchesModule, List<String> modules,
|
||||
String pluginVersion, @DelegatesTo(PluginLayout.PluginLayoutSpec) Closure body = {}) {
|
||||
@DelegatesTo(PluginLayout.PluginLayoutSpec) Closure body = {}) {
|
||||
return PluginLayout.plugin(mainModuleName) {
|
||||
directoryName = name
|
||||
mainJarName = "${name}.jar"
|
||||
version = pluginVersion
|
||||
modules.each { module ->
|
||||
withModule(module, mainJarName, false)
|
||||
}
|
||||
withModule(buildPatchesModule, mainJarName, false)
|
||||
withResourceFromModule("python-helpers", "", "helpers")
|
||||
withCustomVersion { BuildContext context ->
|
||||
// TODO: Make the Python plugin follow the conventional scheme for plugin versioning, build the plugin together with the IDE
|
||||
def pluginBuildNumber = System.getProperty("build.number", "SNAPSHOT")
|
||||
"$context.applicationInfo.majorVersion.$context.applicationInfo.minorVersionMainPart.$pluginBuildNumber"
|
||||
}
|
||||
doNotCreateSeparateJarForLocalizableResources()
|
||||
body.delegate = delegate
|
||||
body()
|
||||
|
||||
Reference in New Issue
Block a user