Skip to content

Commit

Permalink
Merge branch 'main' into ml-eis-integration-jbc
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybcee authored Jan 3, 2025
2 parents 9dd88bf + 34ab4a4 commit 13c0bdf
Show file tree
Hide file tree
Showing 1,293 changed files with 27,744 additions and 5,346 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.elasticsearch.gradle.internal.conventions.util.Util;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
Expand All @@ -35,11 +34,19 @@ public GitInfoPlugin(ProviderFactory factory) {

@Override
public void apply(Project project) {
File rootDir = Util.locateElasticsearchWorkspace(project.getGradle());
File rootDir = getGitRootDir(project);
getGitInfo().convention(factory.of(GitInfoValueSource.class, spec -> { spec.getParameters().getPath().set(rootDir); }));
revision = getGitInfo().map(info -> info.getRevision() == null ? info.getRevision() : "main");
}

private static File getGitRootDir(Project project) {
File rootDir = project.getRootDir();
if (new File(rootDir, ".git").exists()) {
return rootDir;
}
return Util.locateElasticsearchWorkspace(project.getGradle());
}

public abstract Property<GitInfo> getGitInfo();

public Provider<String> getRevision() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
import org.gradle.api.Project;
import org.gradle.api.file.FileTree;
import org.gradle.api.initialization.IncludedBuild;
import org.gradle.api.internal.GradleInternal;
import org.gradle.api.invocation.Gradle;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.util.PatternFilterable;

import javax.annotation.Nullable;
import java.io.File;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;

import javax.annotation.Nullable;

public class Util {

public static boolean getBooleanProperty(String property, boolean defaultValue) {
Expand Down Expand Up @@ -120,6 +121,14 @@ public static SourceSetContainer getJavaSourceSets(Project project) {
return project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
}

public static File getRootFolder(Gradle gradle) {
Gradle parent = gradle.getParent();
if (parent == null) {
return gradle.getRootProject().getRootDir();
}
return getRootFolder(parent);
}

public static File locateElasticsearchWorkspace(Gradle gradle) {
if (gradle.getRootProject().getName().startsWith("build-tools")) {
File buildToolsParent = gradle.getRootProject().getRootDir().getParentFile();
Expand Down
4 changes: 2 additions & 2 deletions build-tools-internal/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=89d4e70e4e84e2d2dfbb63e4daa53e21b25017cc70c37e4eea31ee51fb15098a
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
distributionSha256Sum=7ebdac923867a3cec0098302416d1e3c6c0c729fc4e2e05c10637a8af33a76c5
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
esplugin {
name = 'hello-world-plugin'
classname 'org.acme.HelloWorldPlugin'
classname = 'org.acme.HelloWorldPlugin'
description = "shadowed es plugin"
}
Expand Down Expand Up @@ -375,7 +375,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
esplugin {
name = 'hello-world-plugin'
classname 'org.acme.HelloWorldPlugin'
classname = 'org.acme.HelloWorldPlugin'
description = "custom project description"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ develocity {
link 'Source', "${prBaseUrl}/tree/${System.getenv('BUILDKITE_COMMIT')}"
link 'Pull Request', "https://github.com/${repository}/pull/${prId}"
} else {
value 'Git Commit ID', gitRevision
link 'Source', "https://github.com/${repository}/tree/${gitRevision}"
value 'Git Commit ID', gitRevision.get()
link 'Source', "https://github.com/${repository}/tree/${gitRevision.get()}"
}

buildFinished { result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
tasks.register('buildDependencyArtifacts') {
group = 'ide'
description = 'Builds artifacts needed as dependency for IDE modules'
dependsOn([':plugins:repository-hdfs:hadoop-client-api:shadowJar',
dependsOn([':plugins:repository-hdfs:hadoop-client-api:jar',
':x-pack:plugin:esql:compute:ann:jar',
':x-pack:plugin:esql:compute:gen:jar',
':server:generateModulesList',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum DockerBase {
// Chainguard based wolfi image with latest jdk
// This is usually updated via renovatebot
// spotless:off
WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:bfdeddb33330a281950c2a54adef991dbbe6a42832bc505d13b11beaf50ae73f",
WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:eef54b3a414aa53b98f0f8df2633aed83c3ba6230722769282925442968f0364",
"-wolfi",
"apk"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ private void registerEmptyDirectoryTasks(Project project) {
});

File pluginsDir = new File(project.getBuildDir(), "plugins-hack/plugins");
project.getExtensions().add("pluginsDir", pluginsDir);
project.getExtensions().getExtraProperties().set("pluginsDir", pluginsDir);
project.getTasks().register("createPluginsDir", EmptyDirTask.class, t -> {
t.setDir(pluginsDir);
t.setDirMode(0755);
});

File jvmOptionsDir = new File(project.getBuildDir(), "jvm-options-hack/jvm.options.d");
project.getExtensions().add("jvmOptionsDir", jvmOptionsDir);
project.getExtensions().getExtraProperties().set("jvmOptionsDir", jvmOptionsDir);
project.getTasks().register("createJvmOptionsDir", EmptyDirTask.class, t -> {
t.setDir(jvmOptionsDir);
t.setDirMode(0750);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ private static void configureBwcProject(
// We don't use a normal `Copy` task here as snapshotting the entire gradle user home is very expensive. This task is cheap, so
// up-to-date checking doesn't buy us much
project.getTasks().register("setupGradleUserHome", task -> {
File gradleUserHome = project.getGradle().getGradleUserHomeDir();
String projectName = project.getName();
task.doLast(t -> {
fileSystemOperations.copy(copy -> {
String gradleUserHome = project.getGradle().getGradleUserHomeDir().getAbsolutePath();
copy.into(gradleUserHome + "-" + project.getName());
copy.from(gradleUserHome, copySpec -> {
String absoluteGradleUserHomePath = gradleUserHome.getAbsolutePath();
copy.into(absoluteGradleUserHomePath + "-" + projectName);
copy.from(absoluteGradleUserHomePath, copySpec -> {
copySpec.include("gradle.properties");
copySpec.include("init.d/*");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import java.util.List;

public class InternalElasticsearchDistributionTypes {
public static ElasticsearchDistributionType DEB = new DebElasticsearchDistributionType();
public static ElasticsearchDistributionType RPM = new RpmElasticsearchDistributionType();
public static ElasticsearchDistributionType DOCKER = new DockerElasticsearchDistributionType();
public static ElasticsearchDistributionType DOCKER_IRONBANK = new DockerIronBankElasticsearchDistributionType();
public static ElasticsearchDistributionType DOCKER_CLOUD_ESS = new DockerCloudEssElasticsearchDistributionType();
public static ElasticsearchDistributionType DOCKER_WOLFI = new DockerWolfiElasticsearchDistributionType();
public static final ElasticsearchDistributionType DEB = new DebElasticsearchDistributionType();
public static final ElasticsearchDistributionType RPM = new RpmElasticsearchDistributionType();
public static final ElasticsearchDistributionType DOCKER = new DockerElasticsearchDistributionType();
public static final ElasticsearchDistributionType DOCKER_IRONBANK = new DockerIronBankElasticsearchDistributionType();
public static final ElasticsearchDistributionType DOCKER_CLOUD_ESS = new DockerCloudEssElasticsearchDistributionType();
public static final ElasticsearchDistributionType DOCKER_WOLFI = new DockerWolfiElasticsearchDistributionType();

public static List<ElasticsearchDistributionType> ALL_INTERNAL = List.of(
public static final List<ElasticsearchDistributionType> ALL_INTERNAL = List.of(
DEB,
RPM,
DOCKER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public TaskProvider<? extends Task> createTask(Project project) {
File checkstyleDir = new File(project.getBuildDir(), "checkstyle");
File checkstyleSuppressions = new File(checkstyleDir, "checkstyle_suppressions.xml");
File checkstyleConf = new File(checkstyleDir, "checkstyle.xml");
TaskProvider<Task> copyCheckstyleConf = project.getTasks().register("copyCheckstyleConf");
TaskProvider<CopyCheckStyleConfTask> copyCheckstyleConf = project.getTasks()
.register("copyCheckstyleConf", CopyCheckStyleConfTask.class);
// configure inputs and outputs so up to date works properly
copyCheckstyleConf.configure(t -> t.getOutputs().files(checkstyleSuppressions, checkstyleConf));
if ("jar".equals(checkstyleConfUrl.getProtocol())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.gradle.internal.precommit;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.FileSystemOperations;

import javax.inject.Inject;

public abstract class CopyCheckStyleConfTask extends DefaultTask {

@Inject
public abstract FileSystemOperations getFs();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.specs.Specs;
Expand Down Expand Up @@ -88,8 +89,8 @@ public void apply(Project project) {
Map<String, TaskProvider<?>> versionTasks = versionTasks(project, "destructiveDistroUpgradeTest", buildParams.getBwcVersions());
TaskProvider<Task> destructiveDistroTest = project.getTasks().register("destructiveDistroTest");

Configuration examplePlugin = configureExamplePlugin(project);

Configuration examplePluginConfiguration = configureExamplePlugin(project);
FileCollection examplePluginFileCollection = examplePluginConfiguration;
List<TaskProvider<Test>> windowsTestTasks = new ArrayList<>();
Map<ElasticsearchDistributionType, List<TaskProvider<Test>>> linuxTestTasks = new HashMap<>();

Expand All @@ -102,9 +103,9 @@ public void apply(Project project) {
t2 -> distribution.isDocker() == false || dockerSupport.get().getDockerAvailability().isAvailable()
);
addDistributionSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath);
addDistributionSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePlugin.getSingleFile().toString());
addDistributionSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePluginFileCollection.getSingleFile().toString());
t.exclude("**/PackageUpgradeTests.class");
}, distribution, examplePlugin.getDependencies());
}, distribution, examplePluginConfiguration.getDependencies());

if (distribution.getPlatform() == Platform.WINDOWS) {
windowsTestTasks.add(destructiveTask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public Destination getDestination() {
return Destination.StdErr;
}

@Override
public long getLogTime() {
return result.getEndTime();
}

@Override
public String getMessage() {
return message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TestRerunTaskExtension {
/**
* The name of the extension added to each test task.
*/
public static String NAME = "rerun";
public static final String NAME = "rerun";

private final Property<Integer> maxReruns;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ public String url(String os, String arch, String extension) {
}
}

record EarlyAccessJdkBuild(JavaLanguageVersion languageVersion, String version, String buildNumber) implements JdkBuild {

record EarlyAccessJdkBuild(JavaLanguageVersion languageVersion) implements JdkBuild {
@Override
public String url(String os, String arch, String extension) {
String buildNumber = resolveBuildNumber(languageVersion.asInt());
return "https://download.java.net/java/early_access/jdk"
+ version
+ languageVersion.asInt()
+ "/"
+ version
+ buildNumber
+ "/GPL/openjdk-"
+ version
+ languageVersion.asInt()
+ "-ea+"
+ buildNumber
+ "_"
Expand All @@ -73,6 +73,29 @@ public String url(String os, String arch, String extension) {
+ "_bin."
+ extension;
}

private static String resolveBuildNumber(int version) {
String buildNumber = System.getProperty("runtime.java." + version + ".build");
if (buildNumber != null) {
System.out.println("buildNumber = " + buildNumber);
return buildNumber;
}
buildNumber = System.getProperty("runtime.java.build");
if (buildNumber != null) {
System.out.println("buildNumber2 = " + buildNumber);
return buildNumber;
}

switch (version) {
case 24:
// latest explicitly found build number for 24
return "29";
case 25:
return "3";
default:
throw new IllegalArgumentException("Unsupported version " + version);
}
}
}

private static final Pattern VERSION_PATTERN = Pattern.compile(
Expand All @@ -88,8 +111,8 @@ public String url(String os, String arch, String extension) {
// package private so it can be replaced by tests
List<JdkBuild> builds = List.of(
getBundledJdkBuild(),
// 23 early access
new EarlyAccessJdkBuild(JavaLanguageVersion.of(23), "23", "24")
new EarlyAccessJdkBuild(JavaLanguageVersion.of(24)),
new EarlyAccessJdkBuild(JavaLanguageVersion.of(25))
);

private JdkBuild getBundledJdkBuild() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.11.1
8.12
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package org.elasticsearch.gradle.internal.toolchain

import spock.lang.Unroll

import org.gradle.api.provider.Property
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.toolchain.JavaToolchainDownload
Expand All @@ -26,6 +28,7 @@ import static org.gradle.platform.OperatingSystem.MAC_OS

abstract class AbstractToolchainResolverSpec extends Specification {

@Unroll
def "resolves #os #arch #vendor jdk #langVersion"() {
given:
def resolver = resolverImplementation()
Expand Down
Loading

0 comments on commit 13c0bdf

Please sign in to comment.