Skip to content

Commit 2f17f91

Browse files
committed
Merge remote-tracking branch 'es/master' into ccr
* es/master: (38 commits) Build: Add pom generation to meta plugins (#28321) Add 6.3 version constant to master Minor improvements to translog docs (#28237) [Docs] Remove typo in painless-getting-started.asciidoc Build: Fix meta plugin usage in integ test clusters (#28307) Painless: Add spi jar that will be published for extending whitelists (#28302) mistyping in one of the highlighting examples comment -> content (#28139) Documents applicability of term query to range type (#28166) Build: Omit dependency licenses check for elasticsearch deps (#28304) Clean up commits when global checkpoint advanced (#28140) Implement socket and server ChannelContexts (#28275) Plugins: Fix meta plugins to install bundled plugins with their real name (#28285) Build: Fix meta plugin integ test installation (#28286) Modify Abstract transport tests to use impls (#28270) Fork Groovy compiler onto compile Java home [Docs] Update tophits-aggregation.asciidoc (#28273) Docs: match between snippet to its description (#28296) [TEST] fix RequestTests#testSearch in case search source is not set REST high-level client: remove index suffix from indices client method names (#28263) Fix simple_query_string on invalid input (#28219) ...
2 parents 4754761 + 3a43bb1 commit 2f17f91

File tree

111 files changed

+2599
-1490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+2599
-1490
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ Alternatively, `idea.no.launcher=true` can be set in the
126126
[`idea.properties`](https://www.jetbrains.com/help/idea/file-idea-properties.html)
127127
file which can be accessed under Help > Edit Custom Properties (this will require a
128128
restart of IDEA). For IDEA 2017.3 and above, in addition to the JVM option, you will need to go to
129-
`Run->Edit Configurations->...->Defaults->JUnit` and change the value for the `Shorten command line` setting from
130-
`user-local default: none` to `classpath file`. You may also need to [remove `ant-javafx.jar` from your
129+
`Run->Edit Configurations->...->Defaults->JUnit` and verify that the `Shorten command line` setting is set to
130+
`user-local default: none`. You may also need to [remove `ant-javafx.jar` from your
131131
classpath](https://github.com/elastic/elasticsearch/issues/14348) if that is
132132
reported as a source of jar hell.
133133

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import org.gradle.api.publish.maven.MavenPublication
4343
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
4444
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
4545
import org.gradle.api.tasks.bundling.Jar
46+
import org.gradle.api.tasks.compile.GroovyCompile
4647
import org.gradle.api.tasks.compile.JavaCompile
4748
import org.gradle.api.tasks.javadoc.Javadoc
4849
import org.gradle.internal.jvm.Jvm
@@ -455,6 +456,13 @@ class BuildPlugin implements Plugin<Project> {
455456
// TODO: use native Gradle support for --release when available (cf. https://github.com/gradle/gradle/issues/2510)
456457
options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion
457458
}
459+
// also apply release flag to groovy, which is used in build-tools
460+
project.tasks.withType(GroovyCompile) {
461+
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
462+
options.fork = true
463+
options.forkOptions.javaHome = new File(project.compilerJavaHome)
464+
options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion
465+
}
458466
}
459467
}
460468

@@ -651,7 +659,10 @@ class BuildPlugin implements Plugin<Project> {
651659
Task precommit = PrecommitTasks.create(project, true)
652660
project.check.dependsOn(precommit)
653661
project.test.mustRunAfter(precommit)
654-
project.dependencyLicenses.dependencies = project.configurations.runtime - project.configurations.provided
662+
// only require dependency licenses for non-elasticsearch deps
663+
project.dependencyLicenses.dependencies = project.configurations.runtime.fileCollection {
664+
it.group.startsWith('org.elasticsearch') == false
665+
} - project.configurations.provided
655666
}
656667

657668
private static configureDependenciesInfo(Project project) {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.gradle.plugin
21+
22+
import org.elasticsearch.gradle.BuildPlugin
23+
import org.elasticsearch.gradle.test.RestTestPlugin
24+
import org.elasticsearch.gradle.test.RunTask
25+
import org.elasticsearch.gradle.test.StandaloneRestTestPlugin
26+
import org.gradle.api.Plugin
27+
import org.gradle.api.Project
28+
import org.gradle.api.file.FileCopyDetails
29+
import org.gradle.api.file.RelativePath
30+
import org.gradle.api.tasks.bundling.Zip
31+
32+
class MetaPluginBuildPlugin implements Plugin<Project> {
33+
34+
@Override
35+
void apply(Project project) {
36+
project.plugins.apply(StandaloneRestTestPlugin)
37+
project.plugins.apply(RestTestPlugin)
38+
39+
createBundleTask(project)
40+
41+
project.integTestCluster {
42+
dependsOn(project.bundlePlugin)
43+
plugin(project.path)
44+
}
45+
BuildPlugin.configurePomGeneration(project)
46+
project.afterEvaluate {
47+
PluginBuildPlugin.addZipPomGeneration(project)
48+
}
49+
50+
RunTask run = project.tasks.create('run', RunTask)
51+
run.dependsOn(project.bundlePlugin)
52+
run.clusterConfig.plugin(project.path)
53+
}
54+
55+
private static void createBundleTask(Project project) {
56+
57+
MetaPluginPropertiesTask buildProperties = project.tasks.create('pluginProperties', MetaPluginPropertiesTask.class)
58+
59+
// create the actual bundle task, which zips up all the files for the plugin
60+
Zip bundle = project.tasks.create(name: 'bundlePlugin', type: Zip, dependsOn: [buildProperties]) {
61+
into('elasticsearch') {
62+
from(buildProperties.descriptorOutput.parentFile) {
63+
// plugin properties file
64+
include(buildProperties.descriptorOutput.name)
65+
}
66+
}
67+
// due to how the renames work for each bundled plugin, we must exclude empty dirs or every subdir
68+
// within bundled plugin zips will show up at the root as an empty dir
69+
includeEmptyDirs = false
70+
71+
}
72+
project.assemble.dependsOn(bundle)
73+
74+
// also make the zip available as a configuration (used when depending on this project)
75+
project.configurations.create('zip')
76+
project.artifacts.add('zip', bundle)
77+
78+
// a super hacky way to inject code to run at the end of each of the bundled plugin's configuration
79+
// to add itself back to this meta plugin zip
80+
project.afterEvaluate {
81+
buildProperties.extension.plugins.each { String bundledPluginProjectName ->
82+
Project bundledPluginProject = project.project(bundledPluginProjectName)
83+
bundledPluginProject.afterEvaluate {
84+
bundle.configure {
85+
dependsOn bundledPluginProject.bundlePlugin
86+
from(project.zipTree(bundledPluginProject.bundlePlugin.outputs.files.singleFile)) {
87+
eachFile { FileCopyDetails details ->
88+
// paths in the individual plugins begin with elasticsearch, and we want to add in the
89+
// bundled plugin name between that and each filename
90+
details.relativePath = new RelativePath(true, 'elasticsearch', bundledPluginProjectName,
91+
details.relativePath.toString().replace('elasticsearch/', ''))
92+
}
93+
}
94+
}
95+
}
96+
}
97+
}
98+
}
99+
}

libs/elasticsearch-nio/src/main/java/org/elasticsearch/nio/WriteContext.java renamed to buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/MetaPluginPropertiesExtension.groovy

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,30 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.nio;
20+
package org.elasticsearch.gradle.plugin
2121

22-
import java.io.IOException;
23-
import java.util.function.BiConsumer;
24-
25-
public interface WriteContext {
26-
27-
void sendMessage(Object message, BiConsumer<Void, Throwable> listener);
28-
29-
void queueWriteOperations(WriteOperation writeOperation);
30-
31-
void flushChannel() throws IOException;
32-
33-
boolean hasQueuedWriteOps();
34-
35-
void clearQueuedWriteOps(Exception e);
22+
import org.gradle.api.Project
23+
import org.gradle.api.tasks.Input
3624

25+
/**
26+
* A container for meta plugin properties that will be written to the meta plugin descriptor, for easy
27+
* manipulation in the gradle DSL.
28+
*/
29+
class MetaPluginPropertiesExtension {
30+
@Input
31+
String name
32+
33+
@Input
34+
String description
35+
36+
/**
37+
* The plugins this meta plugin wraps.
38+
* Note this is not written to the plugin descriptor, but used to setup the final zip file task.
39+
*/
40+
@Input
41+
List<String> plugins
42+
43+
MetaPluginPropertiesExtension(Project project) {
44+
name = project.name
45+
}
3746
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.gradle.plugin
21+
22+
import org.gradle.api.InvalidUserDataException
23+
import org.gradle.api.Task
24+
import org.gradle.api.tasks.Copy
25+
import org.gradle.api.tasks.OutputFile
26+
27+
class MetaPluginPropertiesTask extends Copy {
28+
29+
MetaPluginPropertiesExtension extension
30+
31+
@OutputFile
32+
File descriptorOutput = new File(project.buildDir, 'generated-resources/meta-plugin-descriptor.properties')
33+
34+
MetaPluginPropertiesTask() {
35+
File templateFile = new File(project.buildDir, "templates/${descriptorOutput.name}")
36+
Task copyPluginPropertiesTemplate = project.tasks.create('copyPluginPropertiesTemplate') {
37+
doLast {
38+
InputStream resourceTemplate = PluginPropertiesTask.getResourceAsStream("/${descriptorOutput.name}")
39+
templateFile.parentFile.mkdirs()
40+
templateFile.setText(resourceTemplate.getText('UTF-8'), 'UTF-8')
41+
}
42+
}
43+
44+
dependsOn(copyPluginPropertiesTemplate)
45+
extension = project.extensions.create('es_meta_plugin', MetaPluginPropertiesExtension, project)
46+
project.afterEvaluate {
47+
// check require properties are set
48+
if (extension.name == null) {
49+
throw new InvalidUserDataException('name is a required setting for es_meta_plugin')
50+
}
51+
if (extension.description == null) {
52+
throw new InvalidUserDataException('description is a required setting for es_meta_plugin')
53+
}
54+
// configure property substitution
55+
from(templateFile.parentFile).include(descriptorOutput.name)
56+
into(descriptorOutput.parentFile)
57+
Map<String, String> properties = generateSubstitutions()
58+
expand(properties)
59+
inputs.properties(properties)
60+
}
61+
}
62+
63+
Map<String, String> generateSubstitutions() {
64+
return ['name': extension.name,
65+
'description': extension.description
66+
]
67+
}
68+
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.gradle.plugin
2020

21+
import nebula.plugin.info.scm.ScmInfoPlugin
2122
import org.elasticsearch.gradle.BuildPlugin
2223
import org.elasticsearch.gradle.NoticeTask
2324
import org.elasticsearch.gradle.test.RestIntegTestTask
@@ -220,7 +221,8 @@ public class PluginBuildPlugin extends BuildPlugin {
220221
}
221222

222223
/** Adds a task to generate a pom file for the zip distribution. */
223-
protected void addZipPomGeneration(Project project) {
224+
public static void addZipPomGeneration(Project project) {
225+
project.plugins.apply(ScmInfoPlugin.class)
224226
project.plugins.apply(MavenPublishPlugin.class)
225227

226228
project.publishing {

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import org.apache.tools.ant.taskdefs.condition.Os
2323
import org.elasticsearch.gradle.LoggedExec
2424
import org.elasticsearch.gradle.Version
2525
import org.elasticsearch.gradle.VersionProperties
26+
import org.elasticsearch.gradle.plugin.MetaPluginBuildPlugin
27+
import org.elasticsearch.gradle.plugin.MetaPluginPropertiesExtension
2628
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
2729
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension
2830
import org.gradle.api.AntBuilder
@@ -138,8 +140,8 @@ class ClusterFormationTasks {
138140
/** Adds a dependency on a different version of the given plugin, which will be retrieved using gradle's dependency resolution */
139141
static void configureBwcPluginDependency(String name, Project project, Project pluginProject, Configuration configuration, String elasticsearchVersion) {
140142
verifyProjectHasBuildPlugin(name, elasticsearchVersion, project, pluginProject)
141-
PluginPropertiesExtension extension = pluginProject.extensions.findByName('esplugin');
142-
project.dependencies.add(configuration.name, "org.elasticsearch.plugin:${extension.name}:${elasticsearchVersion}@zip")
143+
final String pluginName = findPluginName(pluginProject)
144+
project.dependencies.add(configuration.name, "org.elasticsearch.plugin:${pluginName}:${elasticsearchVersion}@zip")
143145
}
144146

145147
/**
@@ -449,7 +451,7 @@ class ClusterFormationTasks {
449451
configuration = project.configurations.create(configurationName)
450452
}
451453

452-
final String depName = pluginProject.extensions.findByName('esplugin').name
454+
final String depName = findPluginName(pluginProject)
453455

454456
Dependency dep = bwcPlugins.dependencies.find {
455457
it.name == depName
@@ -753,9 +755,19 @@ class ClusterFormationTasks {
753755
}
754756

755757
static void verifyProjectHasBuildPlugin(String name, String version, Project project, Project pluginProject) {
756-
if (pluginProject.plugins.hasPlugin(PluginBuildPlugin) == false) {
758+
if (pluginProject.plugins.hasPlugin(PluginBuildPlugin) == false && pluginProject.plugins.hasPlugin(MetaPluginBuildPlugin) == false) {
757759
throw new GradleException("Task [${name}] cannot add plugin [${pluginProject.path}] with version [${version}] to project's " +
758-
"[${project.path}] dependencies: the plugin is not an esplugin")
760+
"[${project.path}] dependencies: the plugin is not an esplugin or es_meta_plugin")
761+
}
762+
}
763+
764+
/** Find the plugin name in the given project, whether a regular plugin or meta plugin. */
765+
static String findPluginName(Project pluginProject) {
766+
PluginPropertiesExtension extension = pluginProject.extensions.findByName('esplugin')
767+
if (extension != null) {
768+
return extension.name
769+
} else {
770+
return pluginProject.extensions.findByName('es_meta_plugin').name
759771
}
760772
}
761773
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Licensed to Elasticsearch under one or more contributor
3+
# license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright
5+
# ownership. Elasticsearch licenses this file to you under
6+
# the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
implementation-class=org.elasticsearch.gradle.plugin.MetaPluginBuildPlugin

0 commit comments

Comments
 (0)