Skip to content

Commit f844805

Browse files
authored
Merge branch 'main' into esql/reuse-outputset
2 parents ca48602 + a1b0ed1 commit f844805

File tree

1,275 files changed

+22891
-11372
lines changed

Some content is hidden

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

1,275 files changed

+22891
-11372
lines changed

build-conventions/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
plugins {
11-
id "com.gradle.develocity" version "3.18.1"
11+
id "com.gradle.develocity" version "3.19.2"
1212
}
1313

1414
rootProject.name = 'build-conventions'

build-tools-internal/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pluginManagement {
99
}
1010

1111
plugins {
12-
id "com.gradle.develocity" version "3.18.1"
12+
id "com.gradle.develocity" version "3.19.2"
1313
}
1414

1515
dependencyResolutionManagement {

build-tools-internal/src/main/groovy/elasticsearch.bwc-test.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ plugins.withType(InternalJavaRestTestPlugin) {
4747
tasks.withType(StandaloneRestIntegTestTask).configureEach {
4848
testClassesDirs = sourceSets.javaRestTest.output.classesDirs
4949
classpath = sourceSets.javaRestTest.runtimeClasspath
50-
usesDefaultDistribution()
50+
usesDefaultDistribution("BWC tests require full distribution for now")
5151
}
5252
}
5353

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BaseInternalPluginBuildPlugin.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
import org.elasticsearch.gradle.internal.test.ClusterFeaturesMetadataPlugin;
1818
import org.elasticsearch.gradle.plugin.PluginBuildPlugin;
1919
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension;
20-
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster;
21-
import org.elasticsearch.gradle.testclusters.TestClustersPlugin;
2220
import org.elasticsearch.gradle.util.GradleUtils;
23-
import org.gradle.api.NamedDomainObjectContainer;
2421
import org.gradle.api.Plugin;
2522
import org.gradle.api.Project;
2623

@@ -81,29 +78,6 @@ public void doCall() {
8178
if (isModule == false || isXPackModule) {
8279
addNoticeGeneration(project, extension);
8380
}
84-
project.afterEvaluate(p -> {
85-
@SuppressWarnings("unchecked")
86-
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project
87-
.getExtensions()
88-
.getByName(TestClustersPlugin.EXTENSION_NAME);
89-
p.getExtensions().getByType(PluginPropertiesExtension.class).getExtendedPlugins().forEach(pluginName -> {
90-
// Auto add any dependent modules
91-
findModulePath(project, pluginName).ifPresent(
92-
path -> testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.module(path))
93-
);
94-
});
95-
});
96-
}
97-
98-
Optional<String> findModulePath(Project project, String pluginName) {
99-
return project.getRootProject()
100-
.getAllprojects()
101-
.stream()
102-
.filter(p -> GradleUtils.isModuleProject(p.getPath()))
103-
.filter(p -> p.getPlugins().hasPlugin(PluginBuildPlugin.class))
104-
.filter(p -> p.getExtensions().getByType(PluginPropertiesExtension.class).getName().equals(pluginName))
105-
.findFirst()
106-
.map(Project::getPath);
10781
}
10882

10983
/**

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.gradle.api.Task;
2020
import org.gradle.api.file.ArchiveOperations;
2121
import org.gradle.api.plugins.BasePlugin;
22+
import org.gradle.api.provider.ListProperty;
23+
import org.gradle.api.provider.Provider;
2224
import org.gradle.api.tasks.Copy;
2325
import org.gradle.api.tasks.TaskProvider;
2426

@@ -103,22 +105,26 @@ private static TaskProvider<Task> registerCheckMlCppNoticeTask(
103105
) {
104106
TaskProvider<Task> checkMlCppNoticeTask = project.getTasks().register("checkMlCppNotice", task -> {
105107
task.dependsOn(checkExtraction);
108+
final Provider<Path> noticePath = checkExtraction.map(
109+
c -> c.getDestinationDir()
110+
.toPath()
111+
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/modules/x-pack-ml/NOTICE.txt")
112+
);
113+
ListProperty<String> expectedMlLicenses = extension.expectedMlLicenses;
106114
task.doLast(new Action<Task>() {
107115
@Override
108116
public void execute(Task task) {
109117
// this is just a small sample from the C++ notices,
110118
// the idea being that if we've added these lines we've probably added all the required lines
111-
final List<String> expectedLines = extension.expectedMlLicenses.get();
112-
final Path noticePath = checkExtraction.get()
113-
.getDestinationDir()
114-
.toPath()
115-
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/modules/x-pack-ml/NOTICE.txt");
119+
final List<String> expectedLines = expectedMlLicenses.get();
116120
final List<String> actualLines;
117121
try {
118-
actualLines = Files.readAllLines(noticePath);
122+
actualLines = Files.readAllLines(noticePath.get());
119123
for (final String expectedLine : expectedLines) {
120124
if (actualLines.contains(expectedLine) == false) {
121-
throw new GradleException("expected [" + noticePath + " to contain [" + expectedLine + "] but it did not");
125+
throw new GradleException(
126+
"expected [" + noticePath.get() + " to contain [" + expectedLine + "] but it did not"
127+
);
122128
}
123129
}
124130
} catch (IOException ioException) {
@@ -133,43 +139,37 @@ public void execute(Task task) {
133139
private TaskProvider<Task> registerCheckNoticeTask(Project project, TaskProvider<Copy> checkExtraction) {
134140
return project.getTasks().register("checkNotice", task -> {
135141
task.dependsOn(checkExtraction);
136-
task.doLast(new Action<Task>() {
137-
@Override
138-
public void execute(Task task) {
139-
final List<String> noticeLines = Arrays.asList("Elasticsearch", "Copyright 2009-2024 Elasticsearch");
140-
final Path noticePath = checkExtraction.get()
141-
.getDestinationDir()
142-
.toPath()
143-
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/NOTICE.txt");
144-
assertLinesInFile(noticePath, noticeLines);
145-
}
142+
var noticePath = checkExtraction.map(
143+
copy -> copy.getDestinationDir().toPath().resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/NOTICE.txt")
144+
);
145+
task.doLast(t -> {
146+
final List<String> noticeLines = Arrays.asList("Elasticsearch", "Copyright 2009-2024 Elasticsearch");
147+
assertLinesInFile(noticePath.get(), noticeLines);
146148
});
147149
});
148150
}
149151

150152
private TaskProvider<Task> registerCheckLicenseTask(Project project, TaskProvider<Copy> checkExtraction) {
151153
TaskProvider<Task> checkLicense = project.getTasks().register("checkLicense", task -> {
152154
task.dependsOn(checkExtraction);
153-
task.doLast(new Action<Task>() {
154-
@Override
155-
public void execute(Task task) {
156-
String licenseFilename = null;
157-
if (project.getName().contains("oss-") || project.getName().equals("integ-test-zip")) {
158-
licenseFilename = "AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt";
159-
} else {
160-
licenseFilename = "ELASTIC-LICENSE-2.0.txt";
161-
}
162-
final List<String> licenseLines;
163-
try {
164-
licenseLines = Files.readAllLines(project.getRootDir().toPath().resolve("licenses/" + licenseFilename));
165-
final Path licensePath = checkExtraction.get()
166-
.getDestinationDir()
167-
.toPath()
168-
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/LICENSE.txt");
169-
assertLinesInFile(licensePath, licenseLines);
170-
} catch (IOException ioException) {
171-
ioException.printStackTrace();
172-
}
155+
String projectName = project.getName();
156+
Provider<Path> licensePathProvider = checkExtraction.map(
157+
copy -> copy.getDestinationDir().toPath().resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/LICENSE.txt")
158+
);
159+
File rootDir = project.getLayout().getSettingsDirectory().getAsFile();
160+
task.doLast(t -> {
161+
String licenseFilename = null;
162+
if (projectName.contains("oss-") || projectName.equals("integ-test-zip")) {
163+
licenseFilename = "AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt";
164+
} else {
165+
licenseFilename = "ELASTIC-LICENSE-2.0.txt";
166+
}
167+
final List<String> licenseLines;
168+
try {
169+
licenseLines = Files.readAllLines(rootDir.toPath().resolve("licenses/" + licenseFilename));
170+
assertLinesInFile(licensePathProvider.get(), licenseLines);
171+
} catch (IOException ioException) {
172+
ioException.printStackTrace();
173173
}
174174
});
175175
});

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
4949
map.put(LegacyRestTestBasePlugin.class, ":plugins:discovery-ec2");
5050
map.put(LegacyRestTestBasePlugin.class, ":plugins:discovery-gce");
5151
map.put(LegacyRestTestBasePlugin.class, ":plugins:mapper-annotated-text");
52-
map.put(LegacyRestTestBasePlugin.class, ":plugins:mapper-murmur3");
53-
map.put(LegacyRestTestBasePlugin.class, ":plugins:repository-hdfs");
5452
map.put(LegacyRestTestBasePlugin.class, ":plugins:store-smb");
5553
map.put(LegacyRestTestBasePlugin.class, ":qa:ccs-rolling-upgrade-remote-cluster");
5654
map.put(LegacyRestTestBasePlugin.class, ":qa:mixed-cluster");
@@ -74,11 +72,7 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
7472
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search");
7573
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet");
7674
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:logstash");
77-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:mapper-constant-keyword");
78-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:mapper-unsigned-long");
79-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:mapper-version");
8075
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile");
81-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:wildcard");
8276
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:mixed-tier-cluster");
8377
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:repository-old-versions");
8478
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:rolling-upgrade");

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ public void apply(Project project) {
198198
task.getExtensions().getExtraProperties().set("usesDefaultDistribution", new Closure<Void>(task) {
199199
@Override
200200
public Void call(Object... args) {
201+
if (reasonForUsageProvided(args) == false) {
202+
throw new IllegalArgumentException(
203+
"Reason for using `usesDefaultDistribution` required.\nUse usesDefaultDistribution(\"reason why default distro is required here\")."
204+
);
205+
}
201206
task.dependsOn(defaultDistro);
202207
registerDistributionInputs(task, defaultDistro);
203208

@@ -212,6 +217,10 @@ public Void call(Object... args) {
212217

213218
return null;
214219
}
220+
221+
private static boolean reasonForUsageProvided(Object[] args) {
222+
return args.length == 1 && args[0] instanceof String && ((String) args[0]).isBlank() == false;
223+
}
215224
});
216225

217226
// Add `usesBwcDistribution(version)` extension method to test tasks to indicate they require a BWC distribution

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/ArchivedOracleJdkToolchainResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
public abstract class ArchivedOracleJdkToolchainResolver extends AbstractCustomJavaToolchainResolver {
3131

32-
private static final Map<Integer, String> ARCHIVED_BASE_VERSIONS = Maps.of(20, "20.0.2", 19, "19.0.2", 18, "18.0.2.1");
32+
private static final Map<Integer, String> ARCHIVED_BASE_VERSIONS = Maps.of(21, "21.0.6", 20, "20.0.2", 19, "19.0.2", 18, "18.0.2.1");
3333

3434
@Override
3535
public Optional<JavaToolchainDownload> resolve(JavaToolchainRequest request) {

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/OracleOpenJdkToolchainResolver.java

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ public String url(String os, String arch, String extension) {
5858
}
5959
}
6060

61-
record EarlyAccessJdkBuild(JavaLanguageVersion languageVersion) implements JdkBuild {
61+
record EarlyAccessJdkBuild(JavaLanguageVersion languageVersion, String buildNumber) implements JdkBuild {
6262
@Override
6363
public String url(String os, String arch, String extension) {
64-
String buildNumber = resolveBuildNumber(languageVersion.asInt());
6564
return "https://download.java.net/java/early_access/jdk"
6665
+ languageVersion.asInt()
6766
+ "/"
@@ -77,29 +76,6 @@ public String url(String os, String arch, String extension) {
7776
+ "_bin."
7877
+ extension;
7978
}
80-
81-
private static String resolveBuildNumber(int version) {
82-
String buildNumber = System.getProperty("runtime.java." + version + ".build");
83-
if (buildNumber != null) {
84-
System.out.println("buildNumber = " + buildNumber);
85-
return buildNumber;
86-
}
87-
buildNumber = System.getProperty("runtime.java.build");
88-
if (buildNumber != null) {
89-
System.out.println("buildNumber2 = " + buildNumber);
90-
return buildNumber;
91-
}
92-
93-
switch (version) {
94-
case 24:
95-
// latest explicitly found build number for 24
96-
return "29";
97-
case 25:
98-
return "3";
99-
default:
100-
throw new IllegalArgumentException("Unsupported version " + version);
101-
}
102-
}
10379
}
10480

10581
private static final Pattern VERSION_PATTERN = Pattern.compile(
@@ -114,15 +90,20 @@ private static String resolveBuildNumber(int version) {
11490

11591
// package private so it can be replaced by tests
11692
List<JdkBuild> builds = List.of(
117-
getBundledJdkBuild(),
118-
// release candidate of JDK 24
119-
new ReleaseJdkBuild(JavaLanguageVersion.of(24), "download.java.net", "24", "36", "1f9ff9062db4449d8ca828c504ffae90"),
120-
new EarlyAccessJdkBuild(JavaLanguageVersion.of(25))
93+
getBundledJdkBuild(VersionProperties.getBundledJdkVersion(), VersionProperties.getBundledJdkMajorVersion()),
94+
getEarlyAccessBuild(JavaLanguageVersion.of(25), "3")
12195
);
12296

123-
private JdkBuild getBundledJdkBuild() {
124-
String bundledJdkVersion = VersionProperties.getBundledJdkVersion();
125-
JavaLanguageVersion bundledJdkMajorVersion = JavaLanguageVersion.of(VersionProperties.getBundledJdkMajorVersion());
97+
static EarlyAccessJdkBuild getEarlyAccessBuild(JavaLanguageVersion languageVersion, String buildNumber) {
98+
// first try the unversioned override, then the versioned override which has higher precedence
99+
buildNumber = System.getProperty("runtime.java.build", buildNumber);
100+
buildNumber = System.getProperty("runtime.java." + languageVersion.asInt() + ".build", buildNumber);
101+
102+
return new EarlyAccessJdkBuild(languageVersion, buildNumber);
103+
}
104+
105+
static JdkBuild getBundledJdkBuild(String bundledJdkVersion, String bundledJkdMajorVersionString) {
106+
JavaLanguageVersion bundledJdkMajorVersion = JavaLanguageVersion.of(bundledJkdMajorVersionString);
126107
Matcher jdkVersionMatcher = VERSION_PATTERN.matcher(bundledJdkVersion);
127108
if (jdkVersionMatcher.matches() == false) {
128109
throw new IllegalStateException("Unable to parse bundled JDK version " + bundledJdkVersion);

0 commit comments

Comments
 (0)