Skip to content

Commit 88a320f

Browse files
committed
Merge remote-tracking branch 'es/6.x' into ccr-6.x
* es/6.x: (38 commits) Build: Add pom generation to meta plugins (#28321) Add 6.3.0 version constant 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) Fix packaging test when checking for cgroups v2 Plugins: Fix meta plugins to install bundled plugins with their real name (#28285) Build: Fix meta plugin integ test installation (#28286) Fork Groovy compiler onto compile Java home [Docs] Update tophits-aggregation.asciidoc (#28273) Skip restart upgrades for buggy cgroup2 handling Skip packaging upgrade test when cgroups v2 enabled 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 fc89d73 + f668409 commit 88a320f

File tree

73 files changed

+1304
-459
lines changed

Some content is hidden

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

73 files changed

+1304
-459
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

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ task verifyVersions {
146146
*/
147147
allprojects {
148148
ext.bwc_tests_enabled = true
149+
/*
150+
* Versions of Elasticsearch 5.1.1 through 5.3.0 inclusive did not start on versions of Linux with cgroups v2 enabled (kernel >= 4.5).
151+
* This property is provided to all projects that need to check conditionally if they should skip a BWC test task.
152+
*/
153+
ext.cgroupsV2Enabled = Os.isFamily(Os.FAMILY_UNIX) && "mount".execute().text.readLines().any { it =~ /.*type cgroup2.*/ }
149154
}
150155

151156
task verifyBwcTestsEnabled {

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) {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ public class Version {
9797
return otherVersion.suffix == '' || suffix < otherVersion.suffix
9898
}
9999

100+
/**
101+
* Elasticsearch versions 5.1.1 through 5.3.0 fail to start on versions of Linux that support cgroups v2 (kernel >= 4.5). This is a
102+
* convenience method for checking if the current version falls into that range.
103+
*
104+
* @return true if the version is one impacted by the cgroups v2 bug, otherwise false
105+
*/
106+
public boolean isVersionBrokenIfCgroupsV2Enabled() {
107+
return onOrAfter("5.1.1") && onOrBefore("5.3.0")
108+
}
109+
100110
boolean equals(o) {
101111
if (this.is(o)) return true
102112
if (getClass() != o.class) return false
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+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.Project
23+
import org.gradle.api.tasks.Input
24+
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+
}
46+
}
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
/**
@@ -453,7 +455,7 @@ class ClusterFormationTasks {
453455
configuration = project.configurations.create(configurationName)
454456
}
455457

456-
final String depName = pluginProject.extensions.findByName('esplugin').name
458+
final String depName = findPluginName(pluginProject)
457459

458460
Dependency dep = bwcPlugins.dependencies.find {
459461
it.name == depName
@@ -757,9 +759,19 @@ class ClusterFormationTasks {
757759
}
758760

759761
static void verifyProjectHasBuildPlugin(String name, String version, Project project, Project pluginProject) {
760-
if (pluginProject.plugins.hasPlugin(PluginBuildPlugin) == false) {
762+
if (pluginProject.plugins.hasPlugin(PluginBuildPlugin) == false && pluginProject.plugins.hasPlugin(MetaPluginBuildPlugin) == false) {
761763
throw new GradleException("Task [${name}] cannot add plugin [${pluginProject.path}] with version [${version}] to project's " +
762-
"[${project.path}] dependencies: the plugin is not an esplugin")
764+
"[${project.path}] dependencies: the plugin is not an esplugin or es_meta_plugin")
765+
}
766+
}
767+
768+
/** Find the plugin name in the given project, whether a regular plugin or meta plugin. */
769+
static String findPluginName(Project pluginProject) {
770+
PluginPropertiesExtension extension = pluginProject.extensions.findByName('esplugin')
771+
if (extension != null) {
772+
return extension.name
773+
} else {
774+
return pluginProject.extensions.findByName('es_meta_plugin').name
763775
}
764776
}
765777
}
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

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
elasticsearch = 6.2.0
1+
elasticsearch = 6.3.0
22
lucene = 7.2.1
33

44
# optional dependencies

0 commit comments

Comments
 (0)