Skip to content

Commit f25fdf1

Browse files
Merge branch 'main' into inferenceAPIImprovement
2 parents 0624001 + fd0cdf0 commit f25fdf1

File tree

387 files changed

+6855
-2926
lines changed

Some content is hidden

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

387 files changed

+6855
-2926
lines changed

.buildkite/scripts/gradle-configuration-cache-validation.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
set -euo pipefail
44

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

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

1010
# Create a temporary file
1111
tmpOutputFile=$(mktemp)
1212
trap "rm $tmpOutputFile" EXIT
1313

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

1817
# Check if the command was successful
1918
if grep -q "Configuration cache entry reused." $tmpOutputFile; then

TESTING.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ You can run a group of YAML test by using wildcards:
472472
--tests "org.elasticsearch.test.rest.ClientYamlTestSuiteIT.test {yaml=index/*/*}"
473473
---------------------------------------------------------------------------
474474

475-
or
475+
or
476476

477477
---------------------------------------------------------------------------
478478
./gradlew :rest-api-spec:yamlRestTest \
@@ -564,8 +564,8 @@ Sometimes a backward compatibility change spans two versions.
564564
A common case is a new functionality that needs a BWC bridge in an unreleased versioned of a release branch (for example, 5.x).
565565
Another use case, since the introduction of serverless, is to test BWC against main in addition to the other released branches.
566566
To do so, specify the `bwc.refspec` remote and branch to use for the BWC build as `origin/main`.
567-
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],
568-
increment `elasticsearch` in link:./build-tools-internal/version.properties[version.properties], and hard-code the `project.version` for ml-cpp
567+
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],
568+
increment `elasticsearch` in link:./build-tools-internal/version.properties[version.properties], and hard-code the `project.version` for ml-cpp
569569
in link:./x-pack/plugin/ml/build.gradle[ml/build.gradle].
570570

571571
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.
@@ -625,7 +625,7 @@ For specific YAML rest tests one can use
625625
For disabling entire types of tests for subprojects, one can use for example:
626626

627627
------------------------------------------------
628-
if (BuildParams.inFipsJvm){
628+
if (buildParams.inFipsJvm) {
629629
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
630630
tasks.named("javaRestTest").configure{enabled = false }
631631
}

benchmarks/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.elasticsearch.gradle.internal.info.BuildParams
21
import org.elasticsearch.gradle.internal.test.TestUtil
32

43
/*
@@ -78,7 +77,7 @@ tasks.register("copyPainless", Copy) {
7877
}
7978

8079
tasks.named("run").configure {
81-
executable = "${BuildParams.runtimeJavaHome}/bin/java"
80+
executable = "${buildParams.runtimeJavaHome.get()}/bin/java"
8281
args << "-Dplugins.dir=${buildDir}/plugins" << "-Dtests.index=${buildDir}/index"
8382
dependsOn "copyExpression", "copyPainless", configurations.nativeLib
8483
systemProperty 'es.nativelibs.path', TestUtil.getTestLibraryPath(file("../libs/native/libraries/build/platform/").toString())

build-conventions/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder
1212

1313
buildscript {
1414
repositories {
15-
maven {
16-
url 'https://jitpack.io'
17-
}
1815
mavenCentral()
1916
}
2017
}
@@ -70,10 +67,6 @@ gradlePlugin {
7067
}
7168

7269
repositories {
73-
maven {
74-
url 'https://jitpack.io'
75-
}
76-
7770
mavenCentral()
7871
gradlePluginPortal()
7972
}

build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ public abstract class GUtils {
1616
public static String capitalize(String s) {
1717
return s.substring(0, 1).toUpperCase(Locale.ROOT) + s.substring(1);
1818
}
19+
20+
public static <T> T elvis(T given, T fallback) {
21+
if (given == null) {
22+
return fallback;
23+
} else {
24+
return given;
25+
}
26+
}
1927
}

build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/PublishPlugin.java

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
package org.elasticsearch.gradle.internal.conventions;
1111

12-
import org.elasticsearch.gradle.internal.conventions.precommit.PomValidationPrecommitPlugin;
12+
import groovy.util.Node;
13+
1314
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension;
1415
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin;
15-
import groovy.util.Node;
16-
import org.elasticsearch.gradle.internal.conventions.util.Util;
16+
1717
import org.elasticsearch.gradle.internal.conventions.info.GitInfo;
18+
import org.elasticsearch.gradle.internal.conventions.precommit.PomValidationPrecommitPlugin;
19+
import org.elasticsearch.gradle.internal.conventions.util.Util;
1820
import org.gradle.api.NamedDomainObjectSet;
1921
import org.gradle.api.Plugin;
2022
import org.gradle.api.Project;
@@ -35,11 +37,12 @@
3537
import org.gradle.api.tasks.bundling.Jar;
3638
import org.gradle.initialization.layout.BuildLayout;
3739
import org.gradle.language.base.plugins.LifecycleBasePlugin;
40+
import org.w3c.dom.Element;
3841

39-
import javax.inject.Inject;
4042
import java.io.File;
4143
import java.util.Map;
4244
import java.util.concurrent.Callable;
45+
import javax.inject.Inject;
4346

4447
public class PublishPlugin implements Plugin<Project> {
4548

@@ -64,6 +67,7 @@ public void apply(Project project) {
6467
configureSourcesJar(project);
6568
configurePomGeneration(project);
6669
configurePublications(project);
70+
formatGeneratedPom(project);
6771
}
6872

6973
private void configurePublications(Project project) {
@@ -113,29 +117,32 @@ private void configurePomGeneration(Project project) {
113117
var archivesBaseName = providerFactory.provider(() -> getArchivesBaseName(extensions));
114118
var projectVersion = providerFactory.provider(() -> project.getVersion());
115119
var generateMavenPoms = project.getTasks().withType(GenerateMavenPom.class);
116-
generateMavenPoms.configureEach(
117-
pomTask -> pomTask.setDestination(
120+
generateMavenPoms.configureEach(pomTask -> {
121+
pomTask.setDestination(
118122
(Callable<String>) () -> String.format(
119123
"%s/distributions/%s-%s.pom",
120124
projectLayout.getBuildDirectory().get().getAsFile().getPath(),
121125
archivesBaseName.get(),
122126
projectVersion.get()
123127
)
124-
)
125-
);
128+
);
129+
});
130+
126131
var publishing = extensions.getByType(PublishingExtension.class);
127132
final var mavenPublications = publishing.getPublications().withType(MavenPublication.class);
128-
addNameAndDescriptiontoPom(project, mavenPublications);
133+
addNameAndDescriptionToPom(project, mavenPublications);
129134
mavenPublications.configureEach(publication -> {
130-
// Add git origin info to generated POM files for internal builds
131-
publication.getPom().withXml(xml -> addScmInfo(xml, gitInfo.get()));
135+
publication.getPom().withXml(xml -> {
136+
// Add git origin info to generated POM files for internal builds
137+
addScmInfo(xml, gitInfo.get());
138+
});
132139
// have to defer this until archivesBaseName is set
133140
project.afterEvaluate(p -> publication.setArtifactId(archivesBaseName.get()));
134141
generatePomTask.configure(t -> t.dependsOn(generateMavenPoms));
135142
});
136143
}
137144

138-
private void addNameAndDescriptiontoPom(Project project, NamedDomainObjectSet<MavenPublication> mavenPublications) {
145+
private void addNameAndDescriptionToPom(Project project, NamedDomainObjectSet<MavenPublication> mavenPublications) {
139146
var name = project.getName();
140147
var description = providerFactory.provider(() -> project.getDescription() != null ? project.getDescription() : "");
141148
mavenPublications.configureEach(p -> p.getPom().withXml(xml -> {
@@ -186,4 +193,32 @@ static void configureSourcesJar(Project project) {
186193
project.getTasks().named(BasePlugin.ASSEMBLE_TASK_NAME).configure(t -> t.dependsOn(sourcesJarTask));
187194
});
188195
}
196+
197+
198+
/**
199+
* Format the generated pom files to be in a sort of reproducible order.
200+
*/
201+
private void formatGeneratedPom(Project project) {
202+
var publishing = project.getExtensions().getByType(PublishingExtension.class);
203+
final var mavenPublications = publishing.getPublications().withType(MavenPublication.class);
204+
mavenPublications.configureEach(publication -> {
205+
publication.getPom().withXml(xml -> {
206+
// Add some pom formatting
207+
formatDependencies(xml);
208+
});
209+
});
210+
}
211+
212+
/**
213+
* just ensure we put dependencies to the end. more a cosmetic thing than anything else
214+
* */
215+
private void formatDependencies(XmlProvider xml) {
216+
Element rootElement = xml.asElement();
217+
var dependencies = rootElement.getElementsByTagName("dependencies");
218+
if (dependencies.getLength() == 1 && dependencies.item(0) != null) {
219+
org.w3c.dom.Node item = dependencies.item(0);
220+
rootElement.removeChild(item);
221+
rootElement.appendChild(item);
222+
}
223+
}
189224
}

build-tools-internal/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ tasks.named('licenseHeaders').configure {
258258
*****************************************************************************/
259259

260260
repositories {
261-
maven {
262-
url 'https://jitpack.io'
263-
}
264261
mavenCentral()
265262
gradlePluginPortal()
266263
}
@@ -386,10 +383,13 @@ tasks.named("jar") {
386383

387384
spotless {
388385
java {
389-
// IDEs can sometimes run annotation processors that leave files in
390-
// here, causing Spotless to complain. Even though this path ought not
391-
// to exist, exclude it anyway in order to avoid spurious failures.
392-
toggleOffOn()
386+
387+
// workaround for https://github.com/diffplug/spotless/issues/2317
388+
//toggleOffOn()
389+
target project.fileTree("src/main/java") {
390+
include '**/*.java'
391+
exclude '**/DockerBase.java'
392+
}
393393
}
394394
}
395395

build-tools-internal/settings.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
pluginManagement {
22
repositories {
3-
maven {
4-
url 'https://jitpack.io'
5-
}
63
mavenCentral()
74
gradlePluginPortal()
85
}

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/ElasticsearchJavadocPluginFuncTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ElasticsearchJavadocPluginFuncTest extends AbstractGradleFuncTest {
7373
buildFile << """
7474
plugins {
7575
id 'elasticsearch.java-doc'
76-
id 'com.github.johnrengelman.shadow' version '7.1.2'
76+
id 'com.gradleup.shadow'
7777
id 'java'
7878
}
7979
group = 'org.acme.depending'

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPluginFuncTest.groovy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@
99

1010
package org.elasticsearch.gradle.internal
1111

12-
import org.elasticsearch.gradle.Architecture
1312
import org.elasticsearch.gradle.fixtures.AbstractGitAwareGradleFuncTest
1413
import org.gradle.testkit.runner.TaskOutcome
15-
import spock.lang.IgnoreIf
1614
import spock.lang.Unroll
1715

18-
/*
19-
* 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
20-
*/
21-
@IgnoreIf({ Architecture.current() == Architecture.AARCH64 })
2216
class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleFuncTest {
2317

2418
def setup() {

0 commit comments

Comments
 (0)