Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/elastic/elasticsearch into …
Browse files Browse the repository at this point in the history
…esql-kql-function
  • Loading branch information
afoucret committed Nov 19, 2024
2 parents 41f0276 + abc7f58 commit be48540
Show file tree
Hide file tree
Showing 436 changed files with 8,159 additions and 3,340 deletions.
9 changes: 4 additions & 5 deletions .buildkite/scripts/gradle-configuration-cache-validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

set -euo pipefail

# TODO/ FIXIT without a full resolved gradle home, we see issues configuration cache reuse
./gradlew --max-workers=8 --parallel --scan --no-daemon precommit
# This is a workaround for https://github.com/gradle/gradle/issues/28159
.ci/scripts/run-gradle.sh --no-daemon precommit

./gradlew --max-workers=8 --parallel --scan --configuration-cache precommit -Dorg.gradle.configuration-cache.inputs.unsafe.ignore.file-system-checks=build/*.tar.bz2
.ci/scripts/run-gradle.sh --configuration-cache precommit -Dorg.gradle.configuration-cache.inputs.unsafe.ignore.file-system-checks=build/*.tar.bz2

# Create a temporary file
tmpOutputFile=$(mktemp)
trap "rm $tmpOutputFile" EXIT

echo "2nd run"
# TODO run-gradle.sh script causes issues because of init script handling
./gradlew --max-workers=8 --parallel --scan --configuration-cache precommit -Dorg.gradle.configuration-cache.inputs.unsafe.ignore.file-system-checks=build/*.tar.bz2 | tee $tmpOutputFile
.ci/scripts/run-gradle.sh --configuration-cache precommit -Dorg.gradle.configuration-cache.inputs.unsafe.ignore.file-system-checks=build/*.tar.bz2 | tee $tmpOutputFile

# Check if the command was successful
if grep -q "Configuration cache entry reused." $tmpOutputFile; then
Expand Down
8 changes: 4 additions & 4 deletions TESTING.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ You can run a group of YAML test by using wildcards:
--tests "org.elasticsearch.test.rest.ClientYamlTestSuiteIT.test {yaml=index/*/*}"
---------------------------------------------------------------------------

or
or

---------------------------------------------------------------------------
./gradlew :rest-api-spec:yamlRestTest \
Expand Down Expand Up @@ -564,8 +564,8 @@ Sometimes a backward compatibility change spans two versions.
A common case is a new functionality that needs a BWC bridge in an unreleased versioned of a release branch (for example, 5.x).
Another use case, since the introduction of serverless, is to test BWC against main in addition to the other released branches.
To do so, specify the `bwc.refspec` remote and branch to use for the BWC build as `origin/main`.
To test against main, you will also need to create a new version in link:./server/src/main/java/org/elasticsearch/Version.java[Version.java],
increment `elasticsearch` in link:./build-tools-internal/version.properties[version.properties], and hard-code the `project.version` for ml-cpp
To test against main, you will also need to create a new version in link:./server/src/main/java/org/elasticsearch/Version.java[Version.java],
increment `elasticsearch` in link:./build-tools-internal/version.properties[version.properties], and hard-code the `project.version` for ml-cpp
in link:./x-pack/plugin/ml/build.gradle[ml/build.gradle].

In general, to test the changes, you can instruct Gradle to build the BWC version from another remote/branch combination instead of pulling the release branch from GitHub.
Expand Down Expand Up @@ -625,7 +625,7 @@ For specific YAML rest tests one can use
For disabling entire types of tests for subprojects, one can use for example:

------------------------------------------------
if (BuildParams.inFipsJvm){
if (buildParams.inFipsJvm) {
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
tasks.named("javaRestTest").configure{enabled = false }
}
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.internal.test.TestUtil

/*
Expand Down Expand Up @@ -78,7 +77,7 @@ tasks.register("copyPainless", Copy) {
}

tasks.named("run").configure {
executable = "${BuildParams.runtimeJavaHome}/bin/java"
executable = "${buildParams.runtimeJavaHome.get()}/bin/java"
args << "-Dplugins.dir=${buildDir}/plugins" << "-Dtests.index=${buildDir}/index"
dependsOn "copyExpression", "copyPainless", configurations.nativeLib
systemProperty 'es.nativelibs.path', TestUtil.getTestLibraryPath(file("../libs/native/libraries/build/platform/").toString())
Expand Down
7 changes: 0 additions & 7 deletions build-conventions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder

buildscript {
repositories {
maven {
url 'https://jitpack.io'
}
mavenCentral()
}
}
Expand Down Expand Up @@ -70,10 +67,6 @@ gradlePlugin {
}

repositories {
maven {
url 'https://jitpack.io'
}

mavenCentral()
gradlePluginPortal()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ public abstract class GUtils {
public static String capitalize(String s) {
return s.substring(0, 1).toUpperCase(Locale.ROOT) + s.substring(1);
}

public static <T> T elvis(T given, T fallback) {
if (given == null) {
return fallback;
} else {
return given;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

package org.elasticsearch.gradle.internal.conventions;

import org.elasticsearch.gradle.internal.conventions.precommit.PomValidationPrecommitPlugin;
import groovy.util.Node;

import com.github.jengelman.gradle.plugins.shadow.ShadowExtension;
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin;
import groovy.util.Node;
import org.elasticsearch.gradle.internal.conventions.util.Util;

import org.elasticsearch.gradle.internal.conventions.info.GitInfo;
import org.elasticsearch.gradle.internal.conventions.precommit.PomValidationPrecommitPlugin;
import org.elasticsearch.gradle.internal.conventions.util.Util;
import org.gradle.api.NamedDomainObjectSet;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
Expand All @@ -35,11 +37,12 @@
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.initialization.layout.BuildLayout;
import org.gradle.language.base.plugins.LifecycleBasePlugin;
import org.w3c.dom.Element;

import javax.inject.Inject;
import java.io.File;
import java.util.Map;
import java.util.concurrent.Callable;
import javax.inject.Inject;

public class PublishPlugin implements Plugin<Project> {

Expand All @@ -64,6 +67,7 @@ public void apply(Project project) {
configureSourcesJar(project);
configurePomGeneration(project);
configurePublications(project);
formatGeneratedPom(project);
}

private void configurePublications(Project project) {
Expand Down Expand Up @@ -113,29 +117,32 @@ private void configurePomGeneration(Project project) {
var archivesBaseName = providerFactory.provider(() -> getArchivesBaseName(extensions));
var projectVersion = providerFactory.provider(() -> project.getVersion());
var generateMavenPoms = project.getTasks().withType(GenerateMavenPom.class);
generateMavenPoms.configureEach(
pomTask -> pomTask.setDestination(
generateMavenPoms.configureEach(pomTask -> {
pomTask.setDestination(
(Callable<String>) () -> String.format(
"%s/distributions/%s-%s.pom",
projectLayout.getBuildDirectory().get().getAsFile().getPath(),
archivesBaseName.get(),
projectVersion.get()
)
)
);
);
});

var publishing = extensions.getByType(PublishingExtension.class);
final var mavenPublications = publishing.getPublications().withType(MavenPublication.class);
addNameAndDescriptiontoPom(project, mavenPublications);
addNameAndDescriptionToPom(project, mavenPublications);
mavenPublications.configureEach(publication -> {
// Add git origin info to generated POM files for internal builds
publication.getPom().withXml(xml -> addScmInfo(xml, gitInfo.get()));
publication.getPom().withXml(xml -> {
// Add git origin info to generated POM files for internal builds
addScmInfo(xml, gitInfo.get());
});
// have to defer this until archivesBaseName is set
project.afterEvaluate(p -> publication.setArtifactId(archivesBaseName.get()));
generatePomTask.configure(t -> t.dependsOn(generateMavenPoms));
});
}

private void addNameAndDescriptiontoPom(Project project, NamedDomainObjectSet<MavenPublication> mavenPublications) {
private void addNameAndDescriptionToPom(Project project, NamedDomainObjectSet<MavenPublication> mavenPublications) {
var name = project.getName();
var description = providerFactory.provider(() -> project.getDescription() != null ? project.getDescription() : "");
mavenPublications.configureEach(p -> p.getPom().withXml(xml -> {
Expand Down Expand Up @@ -186,4 +193,32 @@ static void configureSourcesJar(Project project) {
project.getTasks().named(BasePlugin.ASSEMBLE_TASK_NAME).configure(t -> t.dependsOn(sourcesJarTask));
});
}


/**
* Format the generated pom files to be in a sort of reproducible order.
*/
private void formatGeneratedPom(Project project) {
var publishing = project.getExtensions().getByType(PublishingExtension.class);
final var mavenPublications = publishing.getPublications().withType(MavenPublication.class);
mavenPublications.configureEach(publication -> {
publication.getPom().withXml(xml -> {
// Add some pom formatting
formatDependencies(xml);
});
});
}

/**
* just ensure we put dependencies to the end. more a cosmetic thing than anything else
* */
private void formatDependencies(XmlProvider xml) {
Element rootElement = xml.asElement();
var dependencies = rootElement.getElementsByTagName("dependencies");
if (dependencies.getLength() == 1 && dependencies.item(0) != null) {
org.w3c.dom.Node item = dependencies.item(0);
rootElement.removeChild(item);
rootElement.appendChild(item);
}
}
}
14 changes: 7 additions & 7 deletions build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ tasks.named('licenseHeaders').configure {
*****************************************************************************/

repositories {
maven {
url 'https://jitpack.io'
}
mavenCentral()
gradlePluginPortal()
}
Expand Down Expand Up @@ -386,10 +383,13 @@ tasks.named("jar") {

spotless {
java {
// IDEs can sometimes run annotation processors that leave files in
// here, causing Spotless to complain. Even though this path ought not
// to exist, exclude it anyway in order to avoid spurious failures.
toggleOffOn()

// workaround for https://github.com/diffplug/spotless/issues/2317
//toggleOffOn()
target project.fileTree("src/main/java") {
include '**/*.java'
exclude '**/DockerBase.java'
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions build-tools-internal/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
pluginManagement {
repositories {
maven {
url 'https://jitpack.io'
}
mavenCentral()
gradlePluginPortal()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ElasticsearchJavadocPluginFuncTest extends AbstractGradleFuncTest {
buildFile << """
plugins {
id 'elasticsearch.java-doc'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.gradleup.shadow'
id 'java'
}
group = 'org.acme.depending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@

package org.elasticsearch.gradle.internal

import org.elasticsearch.gradle.Architecture
import org.elasticsearch.gradle.fixtures.AbstractGitAwareGradleFuncTest
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.IgnoreIf
import spock.lang.Unroll

/*
* Test is ignored on ARM since this test case tests the ability to build certain older BWC branches that we don't support on ARM
*/
@IgnoreIf({ Architecture.current() == Architecture.AARCH64 })
class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleFuncTest {

def setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
plugins {
id 'elasticsearch.java'
id 'elasticsearch.publish'
id 'com.github.johnrengelman.shadow'
id 'com.gradleup.shadow'
}
repositories {
Expand All @@ -117,7 +117,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
}
version = "1.0"
group = 'org.acme'
description = 'some description'
description = 'shadowed project'
"""

when:
Expand All @@ -137,7 +137,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<artifactId>hello-world</artifactId>
<version>1.0</version>
<name>hello-world</name>
<description>some description</description>
<description>shadowed project</description>
<url>unknown</url>
<scm>
<url>unknown</url>
Expand Down Expand Up @@ -186,7 +186,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
plugins {
id 'elasticsearch.java'
id 'elasticsearch.publish'
id 'com.github.johnrengelman.shadow'
id 'com.gradleup.shadow'
}
dependencies {
Expand All @@ -206,7 +206,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
group = 'org.acme'
}
description = 'some description'
description = 'with shadowed dependencies'
"""

when:
Expand All @@ -226,7 +226,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<artifactId>hello-world</artifactId>
<version>1.0</version>
<name>hello-world</name>
<description>some description</description>
<description>with shadowed dependencies</description>
<url>unknown</url>
<scm>
<url>unknown</url>
Expand Down Expand Up @@ -277,13 +277,13 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
plugins {
id 'elasticsearch.internal-es-plugin'
id 'elasticsearch.publish'
id 'com.github.johnrengelman.shadow'
id 'com.gradleup.shadow'
}
esplugin {
name = 'hello-world-plugin'
classname 'org.acme.HelloWorldPlugin'
description = "custom project description"
description = "shadowed es plugin"
}
publishing {
Expand Down Expand Up @@ -324,7 +324,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<artifactId>hello-world-plugin</artifactId>
<version>1.0</version>
<name>hello-world</name>
<description>custom project description</description>
<description>shadowed es plugin</description>
<url>unknown</url>
<scm>
<url>unknown</url>
Expand Down Expand Up @@ -353,7 +353,6 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
<url>https://www.elastic.co</url>
</developer>
</developers>
<dependencies/>
</project>"""
)
}
Expand Down Expand Up @@ -440,8 +439,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
// scm info only added for internal builds
internalBuild()
buildFile << """
BuildParams.init { it.setGitOrigin("https://some-repo.com/repo.git") }
buildParams.getGitOriginProperty().set("https://some-repo.com/repo.git")
apply plugin:'elasticsearch.java'
apply plugin:'elasticsearch.publish'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class SnykDependencyMonitoringGradlePluginFuncTest extends AbstractGradleInterna
},
"target": {
"remoteUrl": "http://acme.org",
"branch": "unknown"
"branch": "$version"
},
"targetReference": "$version",
"projectAttributes": {
Expand Down
Loading

0 comments on commit be48540

Please sign in to comment.