Skip to content

Commit 6d4b637

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Introduce mapping version to index metadata (#33147) Move non duplicated actions back into xpack core (#32952) HLRC: Create server agnostic request and response (#32912) Build: forked compiler max memory matches jvmArgs (#33138) * Added breaking change section for GROUP BY behavior: now it considers null or empty values as a separate group/bucket. Previously, they were ignored. * This is part of backporting of #32832 SQL: Enable aggregations to create a separate bucket for missing values (#32832) [TEST] version guard for reload rest-api-spec Fix grammar in contributing docs APM server monitoring (#32515) Support only string `format` in date, root object & date range (#28117) [Rollup] Move toBuilders() methods out of rollup config objects (#32585) Accept Gradle build scan agreement (#30645) Fix forbiddenapis on java 11 (#33116) Run forbidden api checks with runtimeJavaVersion (#32947) Apply publishing to genreate pom (#33094) Fix a mappings update test (#33146) Reload Secure Settings REST specs & docs (#32990) Refactor CachingUsernamePassword realm (#32646)
2 parents 8ac4999 + 610a9c8 commit 6d4b637

File tree

133 files changed

+5710
-559
lines changed

Some content is hidden

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

133 files changed

+5710
-559
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Contributing to the Elasticsearch codebase
9595
JDK 10 is required to build Elasticsearch. You must have a JDK 10 installation
9696
with the environment variable `JAVA_HOME` referencing the path to Java home for
9797
your JDK 10 installation. By default, tests use the same runtime as `JAVA_HOME`.
98-
However, since Elasticsearch, supports JDK 8 the build supports compiling with
98+
However, since Elasticsearch supports JDK 8, the build supports compiling with
9999
JDK 10 and testing on a JDK 8 runtime; to do this, set `RUNTIME_JAVA_HOME`
100100
pointing to the Java home of a JDK 8 installation. Note that this mechanism can
101101
be used to test against other JDKs as well, this is not only limited to JDK 8.

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ import java.nio.file.Files
3333
import java.nio.file.Path
3434
import java.security.MessageDigest
3535

36+
plugins {
37+
id 'com.gradle.build-scan' version '1.13.2'
38+
}
39+
if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
40+
buildScan {
41+
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
42+
termsOfServiceAgree = 'yes'
43+
}
44+
}
45+
3646
// common maven publishing configuration
3747
subprojects {
3848
group = 'org.elasticsearch'

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@ class BuildPlugin implements Plugin<Project> {
601601
} else {
602602
options.fork = true
603603
options.forkOptions.javaHome = compilerJavaHomeFile
604-
options.forkOptions.memoryMaximumSize = "512m"
605604
}
606605
if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) {
607606
// compile with compact 3 profile by default

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 41 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,12 @@
1818
*/
1919
package org.elasticsearch.gradle.precommit
2020

21-
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
22-
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
23-
import org.gradle.api.JavaVersion
2421
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
25-
import org.gradle.api.JavaVersion
2622
import org.gradle.api.Project
2723
import org.gradle.api.Task
28-
import org.gradle.api.file.FileCollection
24+
import org.gradle.api.artifacts.Configuration
2925
import org.gradle.api.plugins.JavaBasePlugin
3026
import org.gradle.api.plugins.quality.Checkstyle
31-
import org.gradle.api.tasks.JavaExec
32-
import org.gradle.api.tasks.StopExecutionException
33-
3427
/**
3528
* Validation tasks which should be run before committing. These run before tests.
3629
*/
@@ -39,8 +32,8 @@ class PrecommitTasks {
3932
/** Adds a precommit task, which depends on non-test verification tasks. */
4033
public static Task create(Project project, boolean includeDependencyLicenses) {
4134
List<Task> precommitTasks = [
42-
configureForbiddenApis(project),
4335
configureCheckstyle(project),
36+
configureForbiddenApisCli(project),
4437
configureNamingConventions(project),
4538
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
4639
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
@@ -49,9 +42,6 @@ class PrecommitTasks {
4942
project.tasks.create('thirdPartyAudit', ThirdPartyAuditTask.class)
5043
]
5144

52-
// Configure it but don't add it as a dependency yet
53-
configureForbiddenApisCli(project)
54-
5545
// tasks with just tests don't need dependency licenses, so this flag makes adding
5646
// the task optional
5747
if (includeDependencyLicenses) {
@@ -85,77 +75,60 @@ class PrecommitTasks {
8575
return project.tasks.create(precommitOptions)
8676
}
8777

88-
private static Task configureForbiddenApis(Project project) {
89-
project.pluginManager.apply(ForbiddenApisPlugin.class)
90-
project.forbiddenApis {
91-
failOnUnsupportedJava = false
92-
bundledSignatures = ['jdk-unsafe', 'jdk-deprecated', 'jdk-non-portable', 'jdk-system-out']
93-
signaturesURLs = [getClass().getResource('/forbidden/jdk-signatures.txt'),
94-
getClass().getResource('/forbidden/es-all-signatures.txt')]
95-
suppressAnnotations = ['**.SuppressForbidden']
96-
}
97-
project.tasks.withType(CheckForbiddenApis) {
98-
// we do not use the += operator to add signatures, as conventionMappings of Gradle do not work when it's configured using withType:
99-
if (name.endsWith('Test')) {
100-
signaturesURLs = project.forbiddenApis.signaturesURLs +
101-
[ getClass().getResource('/forbidden/es-test-signatures.txt'), getClass().getResource('/forbidden/http-signatures.txt') ]
102-
} else {
103-
signaturesURLs = project.forbiddenApis.signaturesURLs +
104-
[ getClass().getResource('/forbidden/es-server-signatures.txt') ]
105-
}
106-
// forbidden apis doesn't support Java 11, so stop at 10
107-
String targetMajorVersion = (project.compilerJavaVersion.compareTo(JavaVersion.VERSION_1_10) > 0 ?
108-
JavaVersion.VERSION_1_10 :
109-
project.compilerJavaVersion).getMajorVersion()
110-
targetCompatibility = Integer.parseInt(targetMajorVersion) >= 9 ?targetMajorVersion : "1.${targetMajorVersion}"
111-
}
112-
Task forbiddenApis = project.tasks.findByName('forbiddenApis')
113-
forbiddenApis.group = "" // clear group, so this does not show up under verification tasks
114-
115-
return forbiddenApis
116-
}
117-
11878
private static Task configureForbiddenApisCli(Project project) {
119-
project.configurations.create("forbiddenApisCliJar")
79+
Configuration forbiddenApisConfiguration = project.configurations.create("forbiddenApisCliJar")
12080
project.dependencies {
121-
forbiddenApisCliJar 'de.thetaphi:forbiddenapis:2.5'
81+
forbiddenApisCliJar ('de.thetaphi:forbiddenapis:2.5')
12282
}
123-
Task forbiddenApisCli = project.tasks.create('forbiddenApisCli')
83+
Task forbiddenApisCli = project.tasks.create('forbiddenApis')
12484

12585
project.sourceSets.forEach { sourceSet ->
12686
forbiddenApisCli.dependsOn(
127-
project.tasks.create(sourceSet.getTaskName('forbiddenApisCli', null), JavaExec) {
87+
project.tasks.create(sourceSet.getTaskName('forbiddenApis', null), ForbiddenApisCliTask) {
12888
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
12989
dependsOn(buildResources)
130-
classpath = project.files(
131-
project.configurations.forbiddenApisCliJar,
90+
execAction = { spec ->
91+
spec.classpath = project.files(
92+
project.configurations.forbiddenApisCliJar,
93+
sourceSet.compileClasspath,
94+
sourceSet.runtimeClasspath
95+
)
96+
spec.executable = "${project.runtimeJavaHome}/bin/java"
97+
}
98+
inputs.files(
99+
forbiddenApisConfiguration,
132100
sourceSet.compileClasspath,
133101
sourceSet.runtimeClasspath
134102
)
135-
main = 'de.thetaphi.forbiddenapis.cli.CliMain'
136-
executable = "${project.runtimeJavaHome}/bin/java"
137-
args "-b", 'jdk-unsafe-1.8'
138-
args "-b", 'jdk-deprecated-1.8'
139-
args "-b", 'jdk-non-portable'
140-
args "-b", 'jdk-system-out'
141-
args "-f", buildResources.copy("forbidden/jdk-signatures.txt")
142-
args "-f", buildResources.copy("forbidden/es-all-signatures.txt")
143-
args "--suppressannotation", '**.SuppressForbidden'
103+
104+
targetCompatibility = project.compilerJavaVersion
105+
bundledSignatures = [
106+
"jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"
107+
]
108+
signaturesFiles = project.files(
109+
buildResources.copy("forbidden/jdk-signatures.txt"),
110+
buildResources.copy("forbidden/es-all-signatures.txt")
111+
)
112+
suppressAnnotations = ['**.SuppressForbidden']
144113
if (sourceSet.name == 'test') {
145-
args "-f", buildResources.copy("forbidden/es-test-signatures.txt")
146-
args "-f", buildResources.copy("forbidden/http-signatures.txt")
114+
signaturesFiles += project.files(
115+
buildResources.copy("forbidden/es-test-signatures.txt"),
116+
buildResources.copy("forbidden/http-signatures.txt")
117+
)
147118
} else {
148-
args "-f", buildResources.copy("forbidden/es-server-signatures.txt")
119+
signaturesFiles += project.files(buildResources.copy("forbidden/es-server-signatures.txt"))
149120
}
150121
dependsOn sourceSet.classesTaskName
151-
doFirst {
152-
// Forbidden APIs expects only existing dirs, and requires at least one
153-
FileCollection existingOutputs = sourceSet.output.classesDirs
154-
.filter { it.exists() }
155-
if (existingOutputs.isEmpty()) {
156-
throw new StopExecutionException("${sourceSet.name} has no outputs")
157-
}
158-
existingOutputs.forEach { args "-d", it }
122+
classesDirs = sourceSet.output.classesDirs
123+
ext.replaceSignatureFiles = { String... names ->
124+
signaturesFiles = project.files(
125+
names.collect { buildResources.copy("forbidden/${it}.txt") }
126+
)
127+
}
128+
ext.addSignatureFiles = { String... names ->
129+
signaturesFiles += project.files(
130+
names.collect { buildResources.copy("forbidden/${it}.txt") }
131+
)
159132
}
160133
}
161134
)

buildSrc/src/main/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.io.InputStream;
3636
import java.nio.file.Files;
3737
import java.nio.file.Path;
38+
import java.nio.file.StandardCopyOption;
3839
import java.util.Collections;
3940
import java.util.HashSet;
4041
import java.util.Set;
@@ -105,7 +106,7 @@ public void doExport() {
105106
if (is == null) {
106107
throw new GradleException("Can't export `" + resourcePath + "` from build-tools: not found");
107108
}
108-
Files.copy(is, destination);
109+
Files.copy(is, destination, StandardCopyOption.REPLACE_EXISTING);
109110
} catch (IOException e) {
110111
throw new GradleException("Can't write resource `" + resourcePath + "` to " + destination, e);
111112
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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.precommit;
20+
21+
import de.thetaphi.forbiddenapis.cli.CliMain;
22+
import org.gradle.api.Action;
23+
import org.gradle.api.DefaultTask;
24+
import org.gradle.api.JavaVersion;
25+
import org.gradle.api.file.FileCollection;
26+
import org.gradle.api.logging.Logger;
27+
import org.gradle.api.logging.Logging;
28+
import org.gradle.api.tasks.Input;
29+
import org.gradle.api.tasks.InputFiles;
30+
import org.gradle.api.tasks.OutputFile;
31+
import org.gradle.api.tasks.SkipWhenEmpty;
32+
import org.gradle.api.tasks.TaskAction;
33+
import org.gradle.process.JavaExecSpec;
34+
35+
import java.io.File;
36+
import java.io.IOException;
37+
import java.nio.file.Files;
38+
import java.util.ArrayList;
39+
import java.util.Collections;
40+
import java.util.LinkedHashSet;
41+
import java.util.List;
42+
import java.util.Set;
43+
44+
public class ForbiddenApisCliTask extends DefaultTask {
45+
46+
private final Logger logger = Logging.getLogger(ForbiddenApisCliTask.class);
47+
private FileCollection signaturesFiles;
48+
private List<String> signatures = new ArrayList<>();
49+
private Set<String> bundledSignatures = new LinkedHashSet<>();
50+
private Set<String> suppressAnnotations = new LinkedHashSet<>();
51+
private JavaVersion targetCompatibility;
52+
private FileCollection classesDirs;
53+
private Action<JavaExecSpec> execAction;
54+
55+
@Input
56+
public JavaVersion getTargetCompatibility() {
57+
return targetCompatibility;
58+
}
59+
60+
public void setTargetCompatibility(JavaVersion targetCompatibility) {
61+
if (targetCompatibility.compareTo(JavaVersion.VERSION_1_10) > 0) {
62+
logger.warn(
63+
"Target compatibility is set to {} but forbiddenapis only supports up to 10. Will cap at 10.",
64+
targetCompatibility
65+
);
66+
this.targetCompatibility = JavaVersion.VERSION_1_10;
67+
} else {
68+
this.targetCompatibility = targetCompatibility;
69+
}
70+
}
71+
72+
public Action<JavaExecSpec> getExecAction() {
73+
return execAction;
74+
}
75+
76+
public void setExecAction(Action<JavaExecSpec> execAction) {
77+
this.execAction = execAction;
78+
}
79+
80+
@OutputFile
81+
public File getMarkerFile() {
82+
return new File(
83+
new File(getProject().getBuildDir(), "precommit"),
84+
getName()
85+
);
86+
}
87+
88+
@InputFiles
89+
@SkipWhenEmpty
90+
public FileCollection getClassesDirs() {
91+
return classesDirs.filter(File::exists);
92+
}
93+
94+
public void setClassesDirs(FileCollection classesDirs) {
95+
this.classesDirs = classesDirs;
96+
}
97+
98+
@InputFiles
99+
public FileCollection getSignaturesFiles() {
100+
return signaturesFiles;
101+
}
102+
103+
public void setSignaturesFiles(FileCollection signaturesFiles) {
104+
this.signaturesFiles = signaturesFiles;
105+
}
106+
107+
@Input
108+
public List<String> getSignatures() {
109+
return signatures;
110+
}
111+
112+
public void setSignatures(List<String> signatures) {
113+
this.signatures = signatures;
114+
}
115+
116+
@Input
117+
public Set<String> getBundledSignatures() {
118+
return bundledSignatures;
119+
}
120+
121+
public void setBundledSignatures(Set<String> bundledSignatures) {
122+
this.bundledSignatures = bundledSignatures;
123+
}
124+
125+
@Input
126+
public Set<String> getSuppressAnnotations() {
127+
return suppressAnnotations;
128+
}
129+
130+
public void setSuppressAnnotations(Set<String> suppressAnnotations) {
131+
this.suppressAnnotations = suppressAnnotations;
132+
}
133+
134+
@TaskAction
135+
public void runForbiddenApisAndWriteMarker() throws IOException {
136+
getProject().javaexec((JavaExecSpec spec) -> {
137+
execAction.execute(spec);
138+
spec.setMain(CliMain.class.getName());
139+
// build the command line
140+
getSignaturesFiles().forEach(file -> spec.args("-f", file.getAbsolutePath()));
141+
getSuppressAnnotations().forEach(annotation -> spec.args("--suppressannotation", annotation));
142+
getBundledSignatures().forEach(bundled -> {
143+
// there's no option for target compatibility so we have to interpret it
144+
final String prefix;
145+
if (bundled.equals("jdk-system-out") ||
146+
bundled.equals("jdk-reflection") ||
147+
bundled.equals("jdk-non-portable")) {
148+
prefix = "";
149+
} else {
150+
prefix = "-" + (
151+
getTargetCompatibility().compareTo(JavaVersion.VERSION_1_9) >= 0 ?
152+
getTargetCompatibility().getMajorVersion() :
153+
"1." + getTargetCompatibility().getMajorVersion())
154+
;
155+
}
156+
spec.args("-b", bundled + prefix);
157+
}
158+
);
159+
getClassesDirs().forEach(dir ->
160+
spec.args("-d", dir)
161+
);
162+
});
163+
Files.write(getMarkerFile().toPath(), Collections.emptyList());
164+
}
165+
166+
}

client/rest-high-level/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
20-
import org.elasticsearch.gradle.precommit.PrecommitTasks
2119
import org.elasticsearch.gradle.test.RestIntegTestTask
2220
import org.gradle.api.internal.provider.Providers
2321

@@ -75,8 +73,8 @@ dependencyLicenses {
7573
forbiddenApisMain {
7674
// core does not depend on the httpclient for compile so we add the signatures here. We don't add them for test as they are already
7775
// specified
78-
signaturesURLs += [PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
79-
signaturesURLs += [file('src/main/resources/forbidden/rest-high-level-signatures.txt').toURI().toURL()]
76+
addSignatureFiles 'http-signatures'
77+
signaturesFiles += files('src/main/resources/forbidden/rest-high-level-signatures.txt')
8078
}
8179

8280
integTestCluster {

0 commit comments

Comments
 (0)