-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add modules to distributions, and move lang-expression and lang-groovy to them #15233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0a4a81a
caf77f7
da8fe68
88c5388
7942640
f2cebd9
208b46d
763747d
a8e9403
afedd24
7160c5e
699b140
7245d34
f5b6b40
c78c8ba
688935d
784ebb1
01d48e2
2dbd93d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,12 @@ class ClusterFormationTasks { | |
| /** Adds a dependency on the given distribution */ | ||
| static void configureDistributionDependency(Project project, String distro) { | ||
| String elasticsearchVersion = VersionProperties.elasticsearch | ||
| String packaging = distro == 'tar' ? 'tar.gz' : distro | ||
| String packaging = distro | ||
| if (distro == 'tar') { | ||
| packaging = 'tar.gz' | ||
| } else if (distro == 'integ-test-zip') { | ||
| packaging = 'zip' | ||
| } | ||
| project.configurations { | ||
| elasticsearchDistro | ||
| } | ||
|
|
@@ -103,6 +108,12 @@ class ClusterFormationTasks { | |
| setup = configureExtraConfigFilesTask(taskName(task, node, 'extraConfig'), project, setup, node) | ||
| setup = configureCopyPluginsTask(taskName(task, node, 'copyPlugins'), project, setup, node) | ||
|
|
||
| // install modules | ||
| for (Project module : node.config.modules) { | ||
| String actionName = pluginTaskName('install', module.name, 'Module') | ||
| setup = configureInstallModuleTask(taskName(task, node, actionName), project, setup, node, module) | ||
| } | ||
|
|
||
| // install plugins | ||
| for (Map.Entry<String, Object> plugin : node.config.plugins.entrySet()) { | ||
| String actionName = pluginTaskName('install', plugin.getKey(), 'Plugin') | ||
|
|
@@ -138,6 +149,7 @@ class ClusterFormationTasks { | |
| by the source tree. If it isn't then Bad Things(TM) will happen. */ | ||
| Task extract | ||
| switch (node.config.distribution) { | ||
| case 'integ-test-zip': | ||
| case 'zip': | ||
| extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) { | ||
| from { project.zipTree(project.configurations.elasticsearchDistro.singleFile) } | ||
|
|
@@ -286,6 +298,20 @@ class ClusterFormationTasks { | |
| return copyPlugins | ||
| } | ||
|
|
||
| static Task configureInstallModuleTask(String name, Project project, Task setup, NodeInfo node, Project module) { | ||
| if (node.config.distribution != 'integ-test-zip') { | ||
| throw new GradleException("Module ${module.path} not allowed be installed distributions other than integ-test-zip because they should already have all modules bundled!") | ||
| } | ||
| if (module.plugins.hasPlugin(PluginBuildPlugin) == false) { | ||
| throw new GradleException("Task ${name} cannot include module ${module.path} which is not an esplugin") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
| } | ||
| Copy installModule = project.tasks.create(name, Copy.class) | ||
| installModule.dependsOn(setup) | ||
| installModule.into(new File(node.homeDir, "modules/${module.name}")) | ||
| installModule.from({ project.zipTree(module.tasks.bundlePlugin.outputs.files.singleFile) }) | ||
| return installModule | ||
| } | ||
|
|
||
| static Task configureInstallPluginTask(String name, Project project, Task setup, NodeInfo node, Object plugin) { | ||
| FileCollection pluginZip | ||
| if (plugin instanceof Project) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,6 +173,7 @@ class NodeInfo { | |
| static File homeDir(File baseDir, String distro) { | ||
| String path | ||
| switch (distro) { | ||
| case 'integ-test-zip': | ||
| case 'zip': | ||
| case 'tar': | ||
| path = "elasticsearch-${VersionProperties.elasticsearch}" | ||
|
|
@@ -188,8 +189,8 @@ class NodeInfo { | |
| } | ||
|
|
||
| static File confDir(File baseDir, String distro) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for that. |
||
| String Path | ||
| switch (distro) { | ||
| case 'integ-test-zip': | ||
| case 'zip': | ||
| case 'tar': | ||
| return new File(homeDir(baseDir, distro), 'config') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.elasticsearch.action.admin.cluster.node.info; | ||
|
|
||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.io.stream.Streamable; | ||
| import org.elasticsearch.common.xcontent.ToXContent; | ||
| import org.elasticsearch.common.xcontent.XContentBuilder; | ||
| import org.elasticsearch.plugins.PluginInfo; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Information about plugins and modules | ||
| */ | ||
| public class PluginsAndModules implements Streamable, ToXContent { | ||
| private List<PluginInfo> plugins; | ||
| private List<PluginInfo> modules; | ||
|
|
||
| public PluginsAndModules() { | ||
| plugins = new ArrayList<>(); | ||
| modules = new ArrayList<>(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns an ordered list based on plugins name | ||
| */ | ||
| public List<PluginInfo> getPluginInfos() { | ||
| List<PluginInfo> plugins = new ArrayList<>(this.plugins); | ||
| Collections.sort(plugins, (p1, p2) -> p1.getName().compareTo(p2.getName())); | ||
| return plugins; | ||
| } | ||
|
|
||
| /** | ||
| * Returns an ordered list based on modules name | ||
| */ | ||
| public List<PluginInfo> getModuleInfos() { | ||
| List<PluginInfo> modules = new ArrayList<>(this.modules); | ||
| Collections.sort(modules, (p1, p2) -> p1.getName().compareTo(p2.getName())); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to do
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. |
||
| return modules; | ||
| } | ||
|
|
||
| public void addPlugin(PluginInfo info) { | ||
| plugins.add(info); | ||
| } | ||
|
|
||
| public void addModule(PluginInfo info) { | ||
| modules.add(info); | ||
| } | ||
|
|
||
| @Override | ||
| public void readFrom(StreamInput in) throws IOException { | ||
| if (plugins.isEmpty() == false || modules.isEmpty() == false) { | ||
| throw new IllegalStateException("instance is already populated"); | ||
| } | ||
| int plugins_size = in.readInt(); | ||
| for (int i = 0; i < plugins_size; i++) { | ||
| plugins.add(PluginInfo.readFromStream(in)); | ||
| } | ||
| int modules_size = in.readInt(); | ||
| for (int i = 0; i < modules_size; i++) { | ||
| modules.add(PluginInfo.readFromStream(in)); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeInt(plugins.size()); | ||
| for (PluginInfo plugin : getPluginInfos()) { | ||
| plugin.writeTo(out); | ||
| } | ||
| out.writeInt(modules.size()); | ||
| for (PluginInfo module : getModuleInfos()) { | ||
| module.writeTo(out); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
| builder.startArray("plugins"); | ||
| for (PluginInfo pluginInfo : getPluginInfos()) { | ||
| pluginInfo.toXContent(builder, params); | ||
| } | ||
| builder.endArray(); | ||
| // TODO: not ideal, make a better api for this (e.g. with jar metadata, and so on) | ||
| builder.startArray("modules"); | ||
| for (PluginInfo moduleInfo : getModuleInfos()) { | ||
| moduleInfo.toXContent(builder, params); | ||
| } | ||
| builder.endArray(); | ||
|
|
||
| return builder; | ||
| } | ||
| } | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd do it as
String packaging = ['tar': 'tar.gz', 'integ-test-zip': 'zip'][distro] ?: distro.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what is here is much more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.