Skip to content

Commit cad967f

Browse files
committed
Merge branch 'master' into build-flavor-type-leniency
* master: (63 commits) Suppress lease background sync failures if stopping (elastic#40902) [DOCS] Added settings page for ILM. (elastic#40880) [Docs] Remove extraneous text (elastic#40914) Move test classes to test root in Painless (elastic#40873) Fix date index name processor default date_formats (elastic#40915) Source additional files correctly in elasticsearch-cli (elastic#40890) Allow AVX-512 on JDK 11+ (elastic#40828) [Docs] Change example to show col headers (elastic#40822) Update apache httpclient to version 4.5.8 (elastic#40875) Update monitoring-kibana.json (elastic#40899) Introduce Delegating ActionListener Wrappers (elastic#40129) Deprecate old transport settings (elastic#40821) Add Kibana application privileges for monitoring and ml reserved roles (elastic#40651) Use Writeable for TransportReplAction derivatives (elastic#40894) Add test for HTTP and Transport TLS on basic license (elastic#40714) Remove unneded cluster config from test (elastic#40856) Make Fuzziness reject illegal values earlier (elastic#33511) Remove test-only customisation from TransReplAct (elastic#40863) Fix dense/sparse vector limit documentation (elastic#40852) Make -try xlint warning disabled by default. (elastic#40833) ...
2 parents 34daff9 + f92ebb2 commit cad967f

File tree

432 files changed

+135016
-4842
lines changed

Some content is hidden

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

432 files changed

+135016
-4842
lines changed

benchmarks/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies {
3939
runtime 'org.apache.commons:commons-math3:3.2'
4040
}
4141

42-
compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked,-processing"
42+
compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked,-processing"
4343
// enable the JMH's BenchmarkProcessor to generate the final benchmark classes
4444
// needs to be added separately otherwise Gradle will quote it and javac will fail
4545
compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ class BuildPlugin implements Plugin<Project> {
752752
*/
753753
// don't even think about passing args with -J-xxx, oracle will ask you to submit a bug report :)
754754
// fail on all javac warnings
755-
options.compilerArgs << '-Werror' << '-Xlint:all,-path,-serial,-options,-deprecation' << '-Xdoclint:all' << '-Xdoclint:-missing'
755+
options.compilerArgs << '-Werror' << '-Xlint:all,-path,-serial,-options,-deprecation,-try' << '-Xdoclint:all' << '-Xdoclint:-missing'
756756

757757
// either disable annotation processor completely (default) or allow to enable them if an annotation processor is explicitly defined
758758
if (options.compilerArgs.contains("-processor") == false) {

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

+84-34
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
2222
import nebula.plugin.publishing.maven.MavenScmPlugin
2323
import org.elasticsearch.gradle.BuildPlugin
2424
import org.elasticsearch.gradle.NoticeTask
25+
import org.elasticsearch.gradle.Version
26+
import org.elasticsearch.gradle.VersionProperties
2527
import org.elasticsearch.gradle.test.RestIntegTestTask
2628
import org.elasticsearch.gradle.test.RunTask
2729
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
30+
import org.gradle.api.InvalidUserDataException
2831
import org.gradle.api.Project
32+
import org.gradle.api.Task
2933
import org.gradle.api.publish.maven.MavenPublication
3034
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
3135
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
36+
import org.gradle.api.tasks.Copy
3237
import org.gradle.api.tasks.SourceSet
3338
import org.gradle.api.tasks.bundling.Zip
3439
import org.gradle.jvm.tasks.Jar
@@ -38,25 +43,29 @@ import java.util.regex.Pattern
3843
/**
3944
* Encapsulates build configuration for an Elasticsearch plugin.
4045
*/
41-
public class PluginBuildPlugin extends BuildPlugin {
46+
class PluginBuildPlugin extends BuildPlugin {
47+
48+
public static final String PLUGIN_EXTENSION_NAME = 'esplugin'
4249

4350
@Override
44-
public void apply(Project project) {
51+
void apply(Project project) {
4552
super.apply(project)
53+
54+
PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project)
4655
configureDependencies(project)
4756

4857
// this afterEvaluate must happen before the afterEvaluate added by integTest creation,
4958
// so that the file name resolution for installing the plugin will be setup
5059
project.afterEvaluate {
5160
boolean isXPackModule = project.path.startsWith(':x-pack:plugin')
5261
boolean isModule = project.path.startsWith(':modules:') || isXPackModule
53-
String name = project.pluginProperties.extension.name
62+
String name = extension.name
5463
project.archivesBaseName = name
5564

5665
// set the project description so it will be picked up by publishing
57-
project.description = project.pluginProperties.extension.description
66+
project.description = extension.description
5867

59-
configurePublishing(project)
68+
configurePublishing(project, extension)
6069

6170
if (project.plugins.hasPlugin(TestClustersPlugin.class) == false) {
6271
project.integTestCluster.dependsOn(project.tasks.bundlePlugin)
@@ -68,12 +77,23 @@ public class PluginBuildPlugin extends BuildPlugin {
6877
} else {
6978
project.tasks.integTest.dependsOn(project.tasks.bundlePlugin)
7079
if (isModule) {
71-
throw new RuntimeException("Testclusters does not support modules yet");
80+
project.testClusters.integTest.module(
81+
project.file(project.tasks.bundlePlugin.archiveFile)
82+
)
7283
} else {
7384
project.testClusters.integTest.plugin(
7485
project.file(project.tasks.bundlePlugin.archiveFile)
7586
)
7687
}
88+
89+
project.extensions.getByType(PluginPropertiesExtension).extendedPlugins.each { pluginName ->
90+
// Auto add dependent modules to the test cluster
91+
if (project.findProject(":modules:${pluginName}") != null) {
92+
project.testClusters.integTest.module(
93+
project.file(project.project(":modules:${pluginName}").tasks.bundlePlugin.archiveFile)
94+
)
95+
}
96+
}
7797
}
7898

7999
project.tasks.run.dependsOn(project.tasks.bundlePlugin)
@@ -87,7 +107,7 @@ public class PluginBuildPlugin extends BuildPlugin {
87107
}
88108

89109
if (isModule == false || isXPackModule) {
90-
addNoticeGeneration(project)
110+
addNoticeGeneration(project, extension)
91111
}
92112
}
93113
project.testingConventions {
@@ -104,32 +124,28 @@ public class PluginBuildPlugin extends BuildPlugin {
104124
}
105125
}
106126
createIntegTestTask(project)
107-
createBundleTask(project)
127+
createBundleTasks(project, extension)
108128
project.configurations.getByName('default').extendsFrom(project.configurations.getByName('runtime'))
109129
project.tasks.create('run', RunTask) // allow running ES with this plugin in the foreground of a build
110130
}
111131

112-
private void configurePublishing(Project project) {
132+
private void configurePublishing(Project project, PluginPropertiesExtension extension) {
113133
// Only configure publishing if applied externally
114-
if (project.pluginProperties.extension.hasClientJar) {
134+
if (extension.hasClientJar) {
115135
project.plugins.apply(MavenScmPlugin.class)
116136
// Only change Jar tasks, we don't want a -client zip so we can't change archivesBaseName
117137
project.tasks.withType(Jar) {
118138
baseName = baseName + "-client"
119139
}
120140
// always configure publishing for client jars
121141
project.plugins.apply(MavenScmPlugin.class)
122-
project.publishing.publications.nebula(MavenPublication).artifactId(
123-
project.pluginProperties.extension.name + "-client"
124-
)
142+
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name + "-client")
125143
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
126144
generatePOMTask.ext.pomFileName = "${project.archivesBaseName}-client-${project.versions.elasticsearch}.pom"
127145
}
128146
} else {
129147
if (project.plugins.hasPlugin(MavenPublishPlugin)) {
130-
project.publishing.publications.nebula(MavenPublication).artifactId(
131-
project.pluginProperties.extension.name
132-
)
148+
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name)
133149
}
134150

135151
}
@@ -164,24 +180,64 @@ public class PluginBuildPlugin extends BuildPlugin {
164180
* Adds a bundlePlugin task which builds the zip containing the plugin jars,
165181
* metadata, properties, and packaging files
166182
*/
167-
private static void createBundleTask(Project project) {
183+
private static void createBundleTasks(Project project, PluginPropertiesExtension extension) {
168184
File pluginMetadata = project.file('src/main/plugin-metadata')
185+
File templateFile = new File(project.buildDir, "templates/plugin-descriptor.properties")
186+
187+
// create tasks to build the properties file for this plugin
188+
Task copyPluginPropertiesTemplate = project.tasks.create('copyPluginPropertiesTemplate') {
189+
outputs.file(templateFile)
190+
doLast {
191+
InputStream resourceTemplate = PluginBuildPlugin.getResourceAsStream("/${templateFile.name}")
192+
templateFile.setText(resourceTemplate.getText('UTF-8'), 'UTF-8')
193+
}
194+
}
169195

170-
// create a task to build the properties file for this plugin
171-
PluginPropertiesTask buildProperties = project.tasks.create('pluginProperties', PluginPropertiesTask.class)
196+
Copy buildProperties = project.tasks.create('pluginProperties', Copy) {
197+
dependsOn(copyPluginPropertiesTemplate)
198+
from(templateFile)
199+
into("${project.buildDir}/generated-resources")
200+
}
201+
202+
project.afterEvaluate {
203+
// check require properties are set
204+
if (extension.name == null) {
205+
throw new InvalidUserDataException('name is a required setting for esplugin')
206+
}
207+
if (extension.description == null) {
208+
throw new InvalidUserDataException('description is a required setting for esplugin')
209+
}
210+
if (extension.classname == null) {
211+
throw new InvalidUserDataException('classname is a required setting for esplugin')
212+
}
213+
214+
Map<String, String> properties = [
215+
'name': extension.name,
216+
'description': extension.description,
217+
'version': extension.version,
218+
'elasticsearchVersion': Version.fromString(VersionProperties.elasticsearch).toString(),
219+
'javaVersion': project.targetCompatibility as String,
220+
'classname': extension.classname,
221+
'extendedPlugins': extension.extendedPlugins.join(','),
222+
'hasNativeController': extension.hasNativeController,
223+
'requiresKeystore': extension.requiresKeystore
224+
]
225+
226+
buildProperties.configure {
227+
expand(properties)
228+
inputs.properties(properties)
229+
}
230+
}
172231

173232
// add the plugin properties and metadata to test resources, so unit tests can
174233
// know about the plugin (used by test security code to statically initialize the plugin in unit tests)
175234
SourceSet testSourceSet = project.sourceSets.test
176-
testSourceSet.output.dir(buildProperties.descriptorOutput.parentFile, builtBy: 'pluginProperties')
235+
testSourceSet.output.dir(buildProperties.destinationDir, builtBy: buildProperties)
177236
testSourceSet.resources.srcDir(pluginMetadata)
178237

179238
// create the actual bundle task, which zips up all the files for the plugin
180-
Zip bundle = project.tasks.create(name: 'bundlePlugin', type: Zip, dependsOn: [project.jar, buildProperties]) {
181-
from(buildProperties.descriptorOutput.parentFile) {
182-
// plugin properties file
183-
include(buildProperties.descriptorOutput.name)
184-
}
239+
Zip bundle = project.tasks.create(name: 'bundlePlugin', type: Zip) {
240+
from buildProperties
185241
from pluginMetadata // metadata (eg custom security policy)
186242
/*
187243
* If the plugin is using the shadow plugin then we need to bundle
@@ -223,23 +279,17 @@ public class PluginBuildPlugin extends BuildPlugin {
223279
}
224280
}
225281

226-
/** Adds nebula publishing task to generate a pom file for the plugin. */
227-
protected static void addClientJarPomGeneration(Project project) {
228-
project.plugins.apply(MavenScmPlugin.class)
229-
project.description = project.pluginProperties.extension.description
230-
}
231-
232282
/** Configure the pom for the main jar of this plugin */
233283

234-
protected void addNoticeGeneration(Project project) {
235-
File licenseFile = project.pluginProperties.extension.licenseFile
284+
protected void addNoticeGeneration(Project project, PluginPropertiesExtension extension) {
285+
File licenseFile = extension.licenseFile
236286
if (licenseFile != null) {
237287
project.tasks.bundlePlugin.from(licenseFile.parentFile) {
238288
include(licenseFile.name)
239289
rename { 'LICENSE.txt' }
240290
}
241291
}
242-
File noticeFile = project.pluginProperties.extension.noticeFile
292+
File noticeFile = extension.noticeFile
243293
if (noticeFile != null) {
244294
NoticeTask generateNotice = project.tasks.create('generateNotice', NoticeTask.class)
245295
generateNotice.inputFile = noticeFile

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

-82
This file was deleted.

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@ class ClusterFormationTasks {
384384
]
385385
esConfig['node.max_local_storage_nodes'] = node.config.numNodes
386386
esConfig['http.port'] = node.config.httpPort
387-
esConfig['transport.tcp.port'] = node.config.transportPort
387+
if (node.nodeVersion.onOrAfter('6.7.0')) {
388+
esConfig['transport.port'] = node.config.transportPort
389+
} else {
390+
esConfig['transport.tcp.port'] = node.config.transportPort
391+
}
388392
// Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space
389393
esConfig['cluster.routing.allocation.disk.watermark.low'] = '1b'
390394
esConfig['cluster.routing.allocation.disk.watermark.high'] = '1b'

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package org.elasticsearch.gradle.test
2020

2121
import com.carrotsearch.gradle.junit4.RandomizedTestingTask
2222
import org.elasticsearch.gradle.VersionProperties
23-
import org.elasticsearch.gradle.testclusters.ElasticsearchNode
23+
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
2424
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
2525
import org.gradle.api.DefaultTask
2626
import org.gradle.api.Task
@@ -81,10 +81,10 @@ public class RestIntegTestTask extends DefaultTask {
8181
throw new IllegalArgumentException("tests.rest.cluster and tests.cluster must both be null or non-null")
8282
}
8383
if (usesTestclusters == true) {
84-
ElasticsearchNode node = project.testClusters."${name}"
85-
runner.systemProperty('tests.rest.cluster', {node.allHttpSocketURI.join(",") })
86-
runner.systemProperty('tests.config.dir', {node.getConfigDir()})
87-
runner.systemProperty('tests.cluster', {node.transportPortURI})
84+
ElasticsearchCluster cluster = project.testClusters."${name}"
85+
runner.systemProperty('tests.rest.cluster', {cluster.allHttpSocketURI.join(",") })
86+
runner.systemProperty('tests.config.dir', {cluster.singleNode().getConfigDir()})
87+
runner.systemProperty('tests.cluster', {cluster.transportPortURI})
8888
} else {
8989
// we pass all nodes to the rest cluster to allow the clients to round-robin between them
9090
// this is more realistic than just talking to a single node

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ public void checkInvalidPatterns() throws IOException {
111111
.collect(Collectors.toList());
112112

113113
String path = getProject().getRootProject().getProjectDir().toURI().relativize(f.toURI()).toString();
114-
failures = invalidLines.stream()
114+
failures.addAll(invalidLines.stream()
115115
.map(l -> new AbstractMap.SimpleEntry<>(l+1, lines.get(l)))
116116
.flatMap(kv -> patterns.entrySet().stream()
117117
.filter(p -> Pattern.compile(p.getValue()).matcher(kv.getValue()).find())
118118
.map(p -> "- " + p.getKey() + " on line " + kv.getKey() + " of " + path)
119119
)
120-
.collect(Collectors.toList());
120+
.collect(Collectors.toList()));
121121
}
122122
if (failures.isEmpty() == false) {
123123
throw new GradleException("Found invalid patterns:\n" + String.join("\n", failures));

0 commit comments

Comments
 (0)