Skip to content

Commit 53cee21

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: (96 commits) Introduce global checkpoint listeners (#32696) Use JDK 10 for 6.4 BWC builds (#32866) Remove unused imports - follow up to removal of test in issue 32855 Removed flaky test. Looks like randomisation makes these assertions unreliable. This test is superfluous - it was added to address #32770 but it later turned out there was an existing test that just required a fix to provide the missing test coverage. [test] mute IndexShardTests.testDocStats Test: Fix forbidden uses in test framework (#32824) Security: remove password hash bootstrap check (#32440) Move validation to server for put user requests (#32471) [ML] Add high level REST client docs for ML put job endpoint (#32843) Painless: Change fqn_only to no_import (#32817) [test] mute testSearchWithSignificantTermsAgg Backport: CompletableContext class to avoid throwable (#32829) [TEST] Select free port for Minio (#32837) SCRIPTING: Support BucketAggScript return null (#32811) (#32833) HLRC: Add Delete License API (#32586) Aggregations/HL Rest client fix: missing scores (#32774) HLRC: migration get assistance API (#32744) Fix NOOP bulk updates (#32819) Increase logging testRetentionPolicyChangeDuringRecovery AwaitsFix case-functions.sql-spec ...
2 parents a418138 + 3b047ae commit 53cee21

File tree

503 files changed

+14196
-5558
lines changed

Some content is hidden

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

503 files changed

+14196
-5558
lines changed

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

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class BuildPlugin implements Plugin<Project> {
8787
project.pluginManager.apply('nebula.info-scm')
8888
project.pluginManager.apply('nebula.info-jar')
8989

90+
project.getTasks().create("buildResources", ExportElasticsearchBuildResourcesTask)
91+
9092
globalBuildInfo(project)
9193
configureRepositories(project)
9294
configureConfigurations(project)
@@ -101,6 +103,7 @@ class BuildPlugin implements Plugin<Project> {
101103
configureDependenciesInfo(project)
102104
}
103105

106+
104107
/** Performs checks on the build environment and prints information about the build environment. */
105108
static void globalBuildInfo(Project project) {
106109
if (project.rootProject.ext.has('buildChecksDone') == false) {
@@ -116,12 +119,14 @@ class BuildPlugin implements Plugin<Project> {
116119

117120
final Map<Integer, String> javaVersions = [:]
118121
for (int version = 7; version <= Integer.parseInt(minimumCompilerVersion.majorVersion); version++) {
119-
javaVersions.put(version, findJavaHome(version));
122+
if(System.getenv(getJavaHomeEnvVarName(version.toString())) != null) {
123+
javaVersions.put(version, findJavaHome(version.toString()));
124+
}
120125
}
121126

122127
String javaVendor = System.getProperty('java.vendor')
123-
String javaVersion = System.getProperty('java.version')
124-
String gradleJavaVersionDetails = "${javaVendor} ${javaVersion}" +
128+
String gradleJavaVersion = System.getProperty('java.version')
129+
String gradleJavaVersionDetails = "${javaVendor} ${gradleJavaVersion}" +
125130
" [${System.getProperty('java.vm.name')} ${System.getProperty('java.vm.version')}]"
126131

127132
String compilerJavaVersionDetails = gradleJavaVersionDetails
@@ -144,33 +149,33 @@ class BuildPlugin implements Plugin<Project> {
144149
// Build debugging info
145150
println '======================================='
146151
println 'Elasticsearch Build Hamster says Hello!'
147-
println '======================================='
148152
println " Gradle Version : ${project.gradle.gradleVersion}"
149153
println " OS Info : ${System.getProperty('os.name')} ${System.getProperty('os.version')} (${System.getProperty('os.arch')})"
150154
if (gradleJavaVersionDetails != compilerJavaVersionDetails || gradleJavaVersionDetails != runtimeJavaVersionDetails) {
151-
println " JDK Version (gradle) : ${gradleJavaVersionDetails}"
152-
println " JAVA_HOME (gradle) : ${gradleJavaHome}"
153-
println " JDK Version (compile) : ${compilerJavaVersionDetails}"
154-
println " JAVA_HOME (compile) : ${compilerJavaHome}"
155-
println " JDK Version (runtime) : ${runtimeJavaVersionDetails}"
156-
println " JAVA_HOME (runtime) : ${runtimeJavaHome}"
155+
println " Compiler JDK Version : ${getPaddedMajorVersion(compilerJavaVersionEnum)} (${compilerJavaVersionDetails})"
156+
println " Compiler java.home : ${compilerJavaHome}"
157+
println " Runtime JDK Version : ${getPaddedMajorVersion(runtimeJavaVersionEnum)} (${runtimeJavaVersionDetails})"
158+
println " Runtime java.home : ${runtimeJavaHome}"
159+
println " Gradle JDK Version : ${getPaddedMajorVersion(JavaVersion.toVersion(gradleJavaVersion))} (${gradleJavaVersionDetails})"
160+
println " Gradle java.home : ${gradleJavaHome}"
157161
} else {
158-
println " JDK Version : ${gradleJavaVersionDetails}"
162+
println " JDK Version : ${getPaddedMajorVersion(JavaVersion.toVersion(gradleJavaVersion))} (${gradleJavaVersionDetails})"
159163
println " JAVA_HOME : ${gradleJavaHome}"
160164
}
161165
println " Random Testing Seed : ${project.testSeed}"
166+
println '======================================='
162167

163168
// enforce Java version
164169
if (compilerJavaVersionEnum < minimumCompilerVersion) {
165170
final String message =
166-
"the environment variable JAVA_HOME must be set to a JDK installation directory for Java ${minimumCompilerVersion}" +
171+
"the compiler java.home must be set to a JDK installation directory for Java ${minimumCompilerVersion}" +
167172
" but is [${compilerJavaHome}] corresponding to [${compilerJavaVersionEnum}]"
168173
throw new GradleException(message)
169174
}
170175

171176
if (runtimeJavaVersionEnum < minimumRuntimeVersion) {
172177
final String message =
173-
"the environment variable RUNTIME_JAVA_HOME must be set to a JDK installation directory for Java ${minimumRuntimeVersion}" +
178+
"the runtime java.home must be set to a JDK installation directory for Java ${minimumRuntimeVersion}" +
174179
" but is [${runtimeJavaHome}] corresponding to [${runtimeJavaVersionEnum}]"
175180
throw new GradleException(message)
176181
}
@@ -205,6 +210,7 @@ class BuildPlugin implements Plugin<Project> {
205210
project.rootProject.ext.minimumCompilerVersion = minimumCompilerVersion
206211
project.rootProject.ext.minimumRuntimeVersion = minimumRuntimeVersion
207212
project.rootProject.ext.inFipsJvm = inFipsJvm
213+
project.rootProject.ext.gradleJavaVersion = JavaVersion.toVersion(gradleJavaVersion)
208214
}
209215

210216
project.targetCompatibility = project.rootProject.ext.minimumRuntimeVersion
@@ -217,11 +223,20 @@ class BuildPlugin implements Plugin<Project> {
217223
project.ext.runtimeJavaVersion = project.rootProject.ext.runtimeJavaVersion
218224
project.ext.javaVersions = project.rootProject.ext.javaVersions
219225
project.ext.inFipsJvm = project.rootProject.ext.inFipsJvm
226+
project.ext.gradleJavaVersion = project.rootProject.ext.gradleJavaVersion
227+
}
228+
229+
private static String getPaddedMajorVersion(JavaVersion compilerJavaVersionEnum) {
230+
compilerJavaVersionEnum.getMajorVersion().toString().padLeft(2)
220231
}
221232

222233
private static String findCompilerJavaHome() {
223-
final String javaHome = System.getenv('JAVA_HOME')
224-
if (javaHome == null) {
234+
final String compilerJavaHome = System.getenv('JAVA_HOME')
235+
final String compilerJavaProperty = System.getProperty('compiler.java')
236+
if (compilerJavaProperty != null) {
237+
compilerJavaHome = findJavaHome(compilerJavaProperty)
238+
}
239+
if (compilerJavaHome == null) {
225240
if (System.getProperty("idea.active") != null || System.getProperty("eclipse.launcher") != null) {
226241
// IntelliJ does not set JAVA_HOME, so we use the JDK that Gradle was run with
227242
return Jvm.current().javaHome
@@ -233,11 +248,24 @@ class BuildPlugin implements Plugin<Project> {
233248
)
234249
}
235250
}
236-
return javaHome
251+
return compilerJavaHome
237252
}
238253

239-
private static String findJavaHome(int version) {
240-
return System.getenv('JAVA' + version + '_HOME')
254+
private static String findJavaHome(String version) {
255+
String versionedVarName = getJavaHomeEnvVarName(version)
256+
String versionedJavaHome = System.getenv(versionedVarName);
257+
if (versionedJavaHome == null) {
258+
throw new GradleException(
259+
"$versionedVarName must be set to build Elasticsearch. " +
260+
"Note that if the variable was just set you might have to run `./gradlew --stop` for " +
261+
"it to be picked up. See https://github.com/elastic/elasticsearch/issues/31399 details."
262+
)
263+
}
264+
return versionedJavaHome
265+
}
266+
267+
private static String getJavaHomeEnvVarName(String version) {
268+
return 'JAVA' + version + '_HOME'
241269
}
242270

243271
/** Add a check before gradle execution phase which ensures java home for the given java version is set. */
@@ -271,7 +299,10 @@ class BuildPlugin implements Plugin<Project> {
271299
}
272300

273301
private static String findRuntimeJavaHome(final String compilerJavaHome) {
274-
assert compilerJavaHome != null
302+
String runtimeJavaProperty = System.getProperty("runtime.java")
303+
if (runtimeJavaProperty != null) {
304+
return findJavaHome(runtimeJavaProperty)
305+
}
275306
return System.getenv('RUNTIME_JAVA_HOME') ?: compilerJavaHome
276307
}
277308

@@ -769,6 +800,12 @@ class BuildPlugin implements Plugin<Project> {
769800
systemProperty 'tests.security.manager', 'true'
770801
systemProperty 'jna.nosys', 'true'
771802
systemProperty 'es.scripting.exception_for_missing_value', 'true'
803+
systemProperty 'compiler.java', project.ext.compilerJavaVersion.getMajorVersion()
804+
if (project.ext.inFipsJvm) {
805+
systemProperty 'runtime.java', project.ext.runtimeJavaVersion.getMajorVersion() + "FIPS"
806+
} else {
807+
systemProperty 'runtime.java', project.ext.runtimeJavaVersion.getMajorVersion()
808+
}
772809
// TODO: remove setting logging level via system property
773810
systemProperty 'tests.logger.level', 'WARN'
774811
for (Map.Entry<String, String> property : System.properties.entrySet()) {
@@ -783,9 +820,12 @@ class BuildPlugin implements Plugin<Project> {
783820
}
784821
}
785822

786-
// TODO: remove this once joda time is removed from scriptin in 7.0
823+
// TODO: remove this once joda time is removed from scripting in 7.0
787824
systemProperty 'es.scripting.use_java_time', 'true'
788825

826+
// TODO: remove this once ctx isn't added to update script params in 7.0
827+
systemProperty 'es.scripting.update.ctx_in_params', 'false'
828+
789829
// Set the system keystore/truststore password if we're running tests in a FIPS-140 JVM
790830
if (project.inFipsJvm) {
791831
systemProperty 'javax.net.ssl.trustStorePassword', 'password'

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/SnippetsTask.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ public class SnippetsTask extends DefaultTask {
284284
contents.append(line).append('\n')
285285
return
286286
}
287+
// Allow line continuations for console snippets within lists
288+
if (snippet != null && line.trim() == '+') {
289+
return
290+
}
287291
// Just finished
288292
emit()
289293
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
package org.elasticsearch.gradle;
20+
21+
import org.gradle.api.DefaultTask;
22+
import org.gradle.api.GradleException;
23+
import org.gradle.api.file.DirectoryProperty;
24+
import org.gradle.api.file.RegularFileProperty;
25+
import org.gradle.api.logging.Logger;
26+
import org.gradle.api.logging.Logging;
27+
import org.gradle.api.tasks.Classpath;
28+
import org.gradle.api.tasks.Input;
29+
import org.gradle.api.tasks.OutputDirectory;
30+
import org.gradle.api.tasks.SkipWhenEmpty;
31+
import org.gradle.api.tasks.StopExecutionException;
32+
import org.gradle.api.tasks.TaskAction;
33+
34+
import java.io.IOException;
35+
import java.io.InputStream;
36+
import java.nio.file.Files;
37+
import java.nio.file.Path;
38+
import java.util.Collections;
39+
import java.util.HashSet;
40+
import java.util.Set;
41+
42+
/**
43+
* Export Elasticsearch build resources to configurable paths
44+
* <p>
45+
* Wil overwrite existing files and create missing directories.
46+
* Useful for resources that that need to be passed to other processes trough the filesystem or otherwise can't be
47+
* consumed from the classpath.
48+
*/
49+
public class ExportElasticsearchBuildResourcesTask extends DefaultTask {
50+
51+
private final Logger logger = Logging.getLogger(ExportElasticsearchBuildResourcesTask.class);
52+
53+
private final Set<String> resources = new HashSet<>();
54+
55+
private DirectoryProperty outputDir;
56+
57+
public ExportElasticsearchBuildResourcesTask() {
58+
outputDir = getProject().getLayout().directoryProperty(
59+
getProject().getLayout().getBuildDirectory().dir("build-tools-exported")
60+
);
61+
}
62+
63+
@OutputDirectory
64+
public DirectoryProperty getOutputDir() {
65+
return outputDir;
66+
}
67+
68+
@Input
69+
@SkipWhenEmpty
70+
public Set<String> getResources() {
71+
return Collections.unmodifiableSet(resources);
72+
}
73+
74+
@Classpath
75+
public String getResourcesClasspath() {
76+
// This will make sure the task is not considered up to date if the resources are changed.
77+
logger.info("Classpath: {}", System.getProperty("java.class.path"));
78+
return System.getProperty("java.class.path");
79+
}
80+
81+
public void setOutputDir(DirectoryProperty outputDir) {
82+
this.outputDir = outputDir;
83+
}
84+
85+
public RegularFileProperty take(String resource) {
86+
if (getState().getExecuted() || getState().getExecuting()) {
87+
throw new GradleException("buildResources can't be configured after the task ran. " +
88+
"Make sure task is not used after configuration time"
89+
);
90+
}
91+
resources.add(resource);
92+
return getProject().getLayout().fileProperty(outputDir.file(resource));
93+
}
94+
95+
@TaskAction
96+
public void doExport() {
97+
if (resources.isEmpty()) {
98+
throw new StopExecutionException();
99+
}
100+
resources.stream().parallel()
101+
.forEach(resourcePath -> {
102+
Path destination = outputDir.get().file(resourcePath).getAsFile().toPath();
103+
try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourcePath)) {
104+
if (is == null) {
105+
throw new GradleException("Can't export `" + resourcePath + "` from build-tools: not found");
106+
}
107+
Files.copy(is, destination);
108+
} catch (IOException e) {
109+
throw new GradleException("Can't write resource `" + resourcePath + "` to " + destination);
110+
}
111+
});
112+
}
113+
114+
}

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@
720720
<suppress files="modules[/\\]lang-expression[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]expression[/\\]ExpressionScriptEngine.java" checks="LineLength" />
721721
<suppress files="modules[/\\]lang-expression[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]expression[/\\]MoreExpressionTests.java" checks="LineLength" />
722722
<suppress files="modules[/\\]lang-expression[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]expression[/\\]StoredExpressionTests.java" checks="LineLength" />
723+
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ContextExampleTests.java" checks="LineLength" />
723724
<suppress files="modules[/\\]reindex[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]reindex[/\\]TransportUpdateByQueryAction.java" checks="LineLength" />
724725
<suppress files="plugins[/\\]analysis-icu[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]IcuCollationTokenFilterFactory.java" checks="LineLength" />
725726
<suppress files="plugins[/\\]analysis-icu[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]IcuFoldingTokenFilterFactory.java" checks="LineLength" />

0 commit comments

Comments
 (0)