Skip to content

Commit

Permalink
Merge branch 'main' into es-115885-fix-skip-allocation-for-empty-rout…
Browse files Browse the repository at this point in the history
…ing-table
  • Loading branch information
elasticmachine authored Nov 19, 2024
2 parents 9ded79c + 72c4459 commit 708b510
Show file tree
Hide file tree
Showing 413 changed files with 8,951 additions and 5,076 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
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.Action;
import org.gradle.api.NamedDomainObjectSet;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.XmlProvider;
import org.gradle.api.file.ProjectLayout;
import org.gradle.api.plugins.BasePlugin;
Expand Down Expand Up @@ -69,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 @@ -127,42 +126,27 @@ private void configurePomGeneration(Project project) {
projectVersion.get()
)
);
pomTask.doFirst(t -> pomTask.getPom().withXml(xml -> formatDependencies(xml)));
});

var publishing = extensions.getByType(PublishingExtension.class);
final var mavenPublications = publishing.getPublications().withType(MavenPublication.class);

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));
});
}

/**
* 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);
}
}

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 -> {
var root = xml.asNode();
// Node versionNode = root.get("version");
// versionNode.plus(1, "name", name);
root.appendNode("name", name);
root.appendNode("description", description.get());
}));
Expand Down Expand Up @@ -209,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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import java.time.LocalDateTime;

import org.elasticsearch.gradle.Architecture
import org.elasticsearch.gradle.OS
import static org.elasticsearch.gradle.internal.util.CiUtils.safeName

import java.lang.management.ManagementFactory
import java.time.LocalDateTime

// Resolving this early to avoid issues with the build scan plugin in combination with the configuration cache usage
def taskNames = gradle.startParameter.taskNames.join(' ')

develocity {

buildScan {
Expand Down Expand Up @@ -110,7 +114,7 @@ develocity {

// Add a build annotation
// See: https://buildkite.com/docs/agent/v3/cli-annotate
def body = """<div class="mb3"><span class="p1 border rounded">${System.getenv('BUILDKITE_LABEL')}</span> :gradle: ${result.failures ? 'failed' : 'successful'} build: <a href="${scan.buildScanUri}"><code>gradle ${gradle.startParameter.taskNames.join(' ')}</code></a></div>"""
def body = """<div class="mb3"><span class="p1 border rounded">${System.getenv('BUILDKITE_LABEL')}</span> :gradle: ${result.failures ? 'failed' : 'successful'} build: <a href="${scan.buildScanUri}"><code>gradle ${taskNames}</code></a></div>"""
def process = [
'buildkite-agent',
'annotate',
Expand All @@ -131,7 +135,3 @@ develocity {
}
}
}

static def safeName(String string) {
return string.replaceAll(/[^a-zA-Z0-9_\-\.]+/, ' ').trim().replaceAll(' ', '_').toLowerCase()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.elasticsearch.gradle.testclusters.TestDistribution
// Common config when running with a FIPS-140 runtime JVM
if (buildParams.inFipsJvm) {
allprojects {
String javaSecurityFilename = buildParams.runtimeJavaDetails.toLowerCase().contains('oracle') ? 'fips_java_oracle.security' : 'fips_java.security'
String javaSecurityFilename = buildParams.runtimeJavaDetails.get().toLowerCase().contains('oracle') ? 'fips_java_oracle.security' : 'fips_java.security'
File fipsResourcesDir = new File(project.buildDir, 'fips-resources')
File fipsSecurity = new File(fipsResourcesDir, javaSecurityFilename)
File fipsPolicy = new File(fipsResourcesDir, 'fips_java.policy')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {

doLast {
['main', 'test'].each { sourceSet ->
modifyXml(".idea/modules/libs/native/elasticsearch.libs.${project.project(':libs:native').name}.${sourceSet}.iml") { xml ->
modifyXml(".idea/modules/libs/native/elasticsearch.libs.native.${sourceSet}.iml") { xml ->
xml.component.find { it.'@name' == 'NewModuleRootManager' }?.'@LANGUAGE_LEVEL' = 'JDK_21_PREVIEW'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.indices;
package org.elasticsearch.gradle.internal.util;

import org.elasticsearch.Version;
import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature;
public class CiUtils {

import java.util.Map;

public class IndicesFeatures implements FeatureSpecification {
@Override
public Map<NodeFeature, Version> getHistoricalFeatures() {
return Map.of(IndicesService.SUPPORTS_AUTO_PUT, Version.V_8_8_0);
static String safeName(String input) {
return input.replaceAll("[^a-zA-Z0-9_\\-\\.]+", " ").trim().replaceAll(" ", "_").toLowerCase();
}

}
Loading

0 comments on commit 708b510

Please sign in to comment.