diff --git a/build-conventions/build.gradle b/build-conventions/build.gradle index 793adb5a0643a..32fedb22b0868 100644 --- a/build-conventions/build.gradle +++ b/build-conventions/build.gradle @@ -8,6 +8,16 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder + +buildscript { + repositories { + maven { + url 'https://jitpack.io' + } + mavenCentral() + } +} + plugins { id 'java-gradle-plugin' id 'java-test-fixtures' @@ -58,6 +68,10 @@ gradlePlugin { } repositories { + maven { + url 'https://jitpack.io' + } + mavenCentral() gradlePluginPortal() } diff --git a/build-tools-internal/build.gradle b/build-tools-internal/build.gradle index cd521bfa84270..b787454d50a0c 100644 --- a/build-tools-internal/build.gradle +++ b/build-tools-internal/build.gradle @@ -218,6 +218,9 @@ tasks.named('licenseHeaders').configure { *****************************************************************************/ repositories { + maven { + url 'https://jitpack.io' + } mavenCentral() gradlePluginPortal() } diff --git a/build-tools-internal/gradle/wrapper/gradle-wrapper.properties b/build-tools-internal/gradle/wrapper/gradle-wrapper.properties index fcbbad6dd644c..515ab9d5f1822 100644 --- a/build-tools-internal/gradle/wrapper/gradle-wrapper.properties +++ b/build-tools-internal/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=194717442575a6f96e1c1befa2c30e9a4fc90f701d7aee33eb879b79e7ff05c0 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionSha256Sum=f8b4f4772d302c8ff580bc40d0f56e715de69b163546944f787c87abf209c961 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/build-tools-internal/settings.gradle b/build-tools-internal/settings.gradle index 6423750872ca2..1b4fb1215a59d 100644 --- a/build-tools-internal/settings.gradle +++ b/build-tools-internal/settings.gradle @@ -1,5 +1,13 @@ pluginManagement { - includeBuild "../build-conventions" + repositories { + maven { + url 'https://jitpack.io' + } + mavenCentral() + gradlePluginPortal() + } + + includeBuild "../build-conventions" includeBuild "../build-tools" } @@ -9,4 +17,4 @@ dependencyResolutionManagement { from(files("../gradle/build.versions.toml")) } } -} \ No newline at end of file +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java index bfc38e13043b9..d10cecf7fa50e 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java @@ -99,8 +99,8 @@ private void configureGeneralTaskDefaults(Project project) { project.getTasks().withType(AbstractCopyTask.class).configureEach(t -> { t.dependsOn(project.getTasks().withType(EmptyDirTask.class)); t.setIncludeEmptyDirs(true); - t.setDirMode(0755); - t.setFileMode(0644); + t.dirPermissions(permissions -> permissions.unix(0755)); + t.filePermissions(permissions -> permissions.unix(0644)); }); // common config across all archives diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java index f137d9abf480f..9eacb03a3c3a2 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java @@ -23,16 +23,17 @@ import org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin; import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.GradleException; -import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.artifacts.Dependency; +import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.provider.Provider; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Function; -import static org.elasticsearch.gradle.util.GradleUtils.projectDependency; - /** * An internal elasticsearch build plugin that registers additional * distribution resolution strategies to the 'elasticsearch.download-distribution' plugin @@ -64,18 +65,18 @@ public void apply(Project project) { *

* BWC versions are resolved as project to projects under `:distribution:bwc`. */ - private void registerInternalDistributionResolutions(NamedDomainObjectContainer resolutions) { - resolutions.register("localBuild", distributionResolution -> distributionResolution.setResolver((project, distribution) -> { - if (VersionProperties.getElasticsearch().equals(distribution.getVersion())) { + private void registerInternalDistributionResolutions(List resolutions) { + resolutions.add(new DistributionResolution("local-build", (project, distribution) -> { + if (isCurrentVersion(distribution)) { // non-external project, so depend on local build return new ProjectBasedDistributionDependency( - config -> projectDependency(project, distributionProjectPath(distribution), config) + config -> projectDependency(project.getDependencies(), distributionProjectPath(distribution), config) ); } return null; })); - resolutions.register("bwc", distributionResolution -> distributionResolution.setResolver((project, distribution) -> { + resolutions.add(new DistributionResolution("bwc", (project, distribution) -> { BwcVersions.UnreleasedVersionInfo unreleasedInfo = BuildParams.getBwcVersions() .unreleasedInfo(Version.fromString(distribution.getVersion())); if (unreleasedInfo != null) { @@ -89,13 +90,19 @@ private void registerInternalDistributionResolutions(NamedDomainObjectContainer< } String projectConfig = getProjectConfig(distribution, unreleasedInfo); return new ProjectBasedDistributionDependency( - (config) -> projectDependency(project, unreleasedInfo.gradleProjectPath, projectConfig) + (config) -> projectDependency(project.getDependencies(), unreleasedInfo.gradleProjectPath, projectConfig) ); } return null; })); } + private boolean isCurrentVersion(ElasticsearchDistribution distribution) { + Version currentVersionNumber = Version.fromString(VersionProperties.getElasticsearch()); + Version parsedDistVersionNumber = Version.fromString(distribution.getVersion()); + return currentVersionNumber.equals(parsedDistVersionNumber); + } + /** * Will be removed once this is backported to all unreleased branches. */ @@ -110,6 +117,13 @@ private static String getProjectConfig(ElasticsearchDistribution distribution, B } } + private static Dependency projectDependency(DependencyHandler dependencyHandler, String projectPath, String projectConfig) { + Map depConfig = new HashMap<>(); + depConfig.put("path", projectPath); + depConfig.put("configuration", projectConfig); + return dependencyHandler.project(depConfig); + } + private static String distributionProjectPath(ElasticsearchDistribution distribution) { String projectPath = ":distribution"; if (distribution.getType() == ElasticsearchDistributionTypes.INTEG_TEST_ZIP) { diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/SymbolicLinkPreservingTar.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/SymbolicLinkPreservingTar.java index 55d325fbde2c4..68e9e2f452b34 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/SymbolicLinkPreservingTar.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/SymbolicLinkPreservingTar.java @@ -152,7 +152,7 @@ private void visitSymbolicLink(final FileCopyDetailsInternal details) { visitedSymbolicLinks.add(details.getFile()); final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString(), TarConstants.LF_SYMLINK); entry.setModTime(getModTime(details)); - entry.setMode(UnixStat.LINK_FLAG | details.getMode()); + entry.setMode(UnixStat.LINK_FLAG | details.getPermissions().toUnixNumeric()); try { entry.setLinkName(Files.readSymbolicLink(details.getFile().toPath()).toString()); tar.putArchiveEntry(entry); @@ -165,7 +165,7 @@ private void visitSymbolicLink(final FileCopyDetailsInternal details) { private void visitDirectory(final FileCopyDetailsInternal details) { final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString() + "/"); entry.setModTime(getModTime(details)); - entry.setMode(UnixStat.DIR_FLAG | details.getMode()); + entry.setMode(UnixStat.DIR_FLAG | details.getPermissions().toUnixNumeric()); try { tar.putArchiveEntry(entry); tar.closeArchiveEntry(); @@ -177,7 +177,7 @@ private void visitDirectory(final FileCopyDetailsInternal details) { private void visitFile(final FileCopyDetailsInternal details) { final TarArchiveEntry entry = new TarArchiveEntry(details.getRelativePath().getPathString()); entry.setModTime(getModTime(details)); - entry.setMode(UnixStat.FILE_FLAG | details.getMode()); + entry.setMode(UnixStat.FILE_FLAG | details.getPermissions().toUnixNumeric()); entry.setSize(details.getSize()); try { tar.putArchiveEntry(entry); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java index 2d21241b3c7c0..205886314609e 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java @@ -262,7 +262,7 @@ private List getAvailableJavaVersions() { private Stream getAvailableJavaInstallationLocationSteam() { return Stream.concat( javaInstallationRegistry.toolchains().stream().map(metadata -> metadata.location), - Stream.of(new InstallationLocation(Jvm.current().getJavaHome(), "Current JVM")) + Stream.of(InstallationLocation.userDefined(Jvm.current().getJavaHome(), "Current JVM")) ); } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesPrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesPrecommitPlugin.java index 3bc6697930198..b1d9cbd1f01d1 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesPrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesPrecommitPlugin.java @@ -12,27 +12,23 @@ import org.elasticsearch.gradle.internal.conventions.precommit.PrecommitPlugin; import org.gradle.api.Project; import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.ProjectDependency; +import org.gradle.api.artifacts.component.ComponentIdentifier; +import org.gradle.api.artifacts.component.ModuleComponentIdentifier; import org.gradle.api.plugins.JavaPlugin; +import org.gradle.api.specs.Spec; import org.gradle.api.tasks.TaskProvider; public class DependencyLicensesPrecommitPlugin extends PrecommitPlugin { + private static Spec COMPONENT_FILTER = identifier -> (identifier instanceof ModuleComponentIdentifier) + && ((ModuleComponentIdentifier) identifier).getGroup().startsWith("org.elasticsearch") == false; @Override public TaskProvider createTask(Project project) { project.getPlugins().apply(CompileOnlyResolvePlugin.class); - TaskProvider dependencyLicenses = project.getTasks() - .register("dependencyLicenses", DependencyLicensesTask.class); - - // only require dependency licenses for non-elasticsearch deps - dependencyLicenses.configure(t -> { - Configuration runtimeClasspath = project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME); - Configuration compileOnly = project.getConfigurations() - .getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME); - t.setDependencies( - runtimeClasspath.fileCollection(dependency -> dependency instanceof ProjectDependency == false).minus(compileOnly) - ); + var dependencyLicenses = project.getTasks().register("dependencyLicenses", DependencyLicensesTask.class, t -> { + var runtimeClasspath = project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME); + var compileOnly = project.getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME); + t.configureDependencies(runtimeClasspath, compileOnly, COMPONENT_FILTER); }); return dependencyLicenses; } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesTask.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesTask.java index 0b4aff58ee3ab..0d34a3c56e217 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesTask.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesTask.java @@ -11,6 +11,8 @@ import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; import org.gradle.api.InvalidUserDataException; +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.component.ComponentIdentifier; import org.gradle.api.file.Directory; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.FileCollection; @@ -18,7 +20,9 @@ import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging; import org.gradle.api.model.ObjectFactory; +import org.gradle.api.provider.Property; import org.gradle.api.provider.Provider; +import org.gradle.api.specs.Spec; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.InputDirectory; import org.gradle.api.tasks.InputFiles; @@ -41,6 +45,8 @@ import javax.inject.Inject; +import static org.elasticsearch.gradle.internal.util.DependenciesUtils.createFileCollectionFromNonTransitiveArtifactsView; + /** * A task to check licenses for dependencies. *

@@ -83,7 +89,7 @@ * for the dependency. This artifact will be redistributed by us with the release to * comply with the license terms. */ -public class DependencyLicensesTask extends DefaultTask { +public abstract class DependencyLicensesTask extends DefaultTask { private final Pattern regex = Pattern.compile("-v?\\d+.*"); @@ -183,6 +189,10 @@ public void ignoreFile(String file) { ignoreFiles.add(file); } + @Input + @Optional + public abstract Property> getComponentFilter(); + @TaskAction public void checkDependencies() { if (dependencies == null) { @@ -297,7 +307,6 @@ private String getFileName(String name, Map counters, String type) { // try the other suffix...TODO: get rid of this, just support ending in .txt return fileName + ".txt"; } - return fileName; } @@ -312,4 +321,15 @@ public LinkedHashMap getMappings() { return new LinkedHashMap<>(mappings); } + /** + * Convencience method for configuring dependencies to be checked and ignoring transitive dependencies for now. + * */ + public void configureDependencies( + Configuration plusConfiguration, + Configuration minusConfiguration, + Spec componentFilter + ) { + setDependencies(createFileCollectionFromNonTransitiveArtifactsView(plusConfiguration, componentFilter).minus(minusConfiguration)); + } + } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ThirdPartyAuditPrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ThirdPartyAuditPrecommitPlugin.java index f97c8e824c55a..19299bdd2b93f 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ThirdPartyAuditPrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ThirdPartyAuditPrecommitPlugin.java @@ -15,11 +15,14 @@ import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.component.ModuleComponentIdentifier; import org.gradle.api.tasks.TaskProvider; import java.io.File; import java.nio.file.Path; +import static org.elasticsearch.gradle.internal.util.DependenciesUtils.createFileCollectionFromNonTransitiveArtifactsView; + public class ThirdPartyAuditPrecommitPlugin extends PrecommitPlugin { public static final String JDK_JAR_HELL_CONFIG_NAME = "jdkJarHell"; @@ -54,12 +57,14 @@ public TaskProvider createTask(Project project) { Configuration compileOnly = project.getConfigurations() .getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME); t.setClasspath(runtimeConfiguration.plus(compileOnly)); - t.getJarsToScan().from(runtimeConfiguration.fileCollection(dep -> { - // These are SelfResolvingDependency, and some of them backed by file collections, like the Gradle API files, - // or dependencies added as `files(...)`, we can't be sure if those are third party or not. - // err on the side of scanning these to make sure we don't miss anything - return dep.getGroup() != null && dep.getGroup().startsWith("org.elasticsearch") == false; - })); + t.getJarsToScan() + .from( + createFileCollectionFromNonTransitiveArtifactsView( + runtimeConfiguration, + identifier -> identifier instanceof ModuleComponentIdentifier + && ((ModuleComponentIdentifier) identifier).getGroup().startsWith("org.elasticsearch") == false + ) + ); t.dependsOn(resourcesTask); if (BuildParams.getIsRuntimeJavaHomeSet()) { t.getJavaHome().set(project.provider(BuildParams::getRuntimeJavaHome).map(File::getPath)); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/DistroTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/DistroTestPlugin.java index 18ceb931343d0..36cc4cdcbf63a 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/DistroTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/DistroTestPlugin.java @@ -121,17 +121,12 @@ public void apply(Project project) { for (ElasticsearchDistribution distribution : testDistributions) { String taskname = destructiveDistroTestTaskName(distribution); - TaskProvider depsTask = project.getTasks().register(taskname + "#deps"); - // explicitly depend on the archive not on the implicit extracted distribution - depsTask.configure(t -> t.dependsOn(distribution.getArchiveDependencies())); - depsTask.configure(t -> t.dependsOn(examplePlugin.getDependencies())); - depsTasks.put(taskname, depsTask); TaskProvider destructiveTask = configureTestTask(project, taskname, distribution, t -> { t.onlyIf(t2 -> distribution.isDocker() == false || dockerSupport.get().getDockerAvailability().isAvailable); addSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath); addSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePlugin.getSingleFile().toString()); t.exclude("**/PackageUpgradeTests.class"); - }, depsTask); + }, distribution, examplePlugin.getDependencies()); if (distribution.getPlatform() == Platform.WINDOWS) { windowsTestTasks.add(destructiveTask); @@ -159,14 +154,11 @@ public void apply(Project project) { } String upgradeTaskname = destructiveDistroUpgradeTestTaskName(distribution, version.toString()); - TaskProvider upgradeDepsTask = project.getTasks().register(upgradeTaskname + "#deps"); - upgradeDepsTask.configure(t -> t.dependsOn(distribution, bwcDistro)); - depsTasks.put(upgradeTaskname, upgradeDepsTask); TaskProvider upgradeTest = configureTestTask(project, upgradeTaskname, distribution, t -> { addSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath); addSysprop(t, BWC_DISTRIBUTION_SYSPROP, bwcDistro::getFilepath); t.include("**/PackageUpgradeTests.class"); - }, upgradeDepsTask); + }, distribution, bwcDistro); versionTasks.get(version.toString()).configure(t -> t.dependsOn(upgradeTest)); upgradeTestTasks.computeIfAbsent(version.toString(), k -> new ArrayList<>()).add(upgradeTest); } @@ -447,6 +439,7 @@ private static ElasticsearchDistribution createDistro( if (isDocker == false) { d.setBundledJdk(bundledJdk); } + d.setPreferArchive(true); d.setVersion(version); }); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/util/DependenciesUtils.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/util/DependenciesUtils.java new file mode 100644 index 0000000000000..081c28c14fd91 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/util/DependenciesUtils.java @@ -0,0 +1,49 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.internal.util; + +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.ResolvableDependencies; +import org.gradle.api.artifacts.component.ComponentIdentifier; +import org.gradle.api.artifacts.result.ResolvedComponentResult; +import org.gradle.api.artifacts.result.ResolvedDependencyResult; +import org.gradle.api.file.FileCollection; +import org.gradle.api.specs.AndSpec; +import org.gradle.api.specs.Spec; + +import java.util.Set; +import java.util.stream.Collectors; + +public class DependenciesUtils { + + public static FileCollection createFileCollectionFromNonTransitiveArtifactsView( + Configuration configuration, + Spec componentFilter + ) { + ResolvableDependencies incoming = configuration.getIncoming(); + return incoming.artifactView(viewConfiguration -> { + Set firstLevelDependencyComponents = incoming.getResolutionResult() + .getRootComponent() + .map( + rootComponent -> rootComponent.getDependencies() + .stream() + .filter(dependency -> dependency instanceof ResolvedDependencyResult) + .map(dependency -> (ResolvedDependencyResult) dependency) + .filter(dependency -> dependency.getSelected() instanceof ResolvedComponentResult) + .map(dependency -> dependency.getSelected().getId()) + .collect(Collectors.toSet()) + ) + .get(); + viewConfiguration.componentFilter( + new AndSpec<>(identifier -> firstLevelDependencyComponents.contains(identifier), componentFilter) + ); + }).getFiles(); + } + +} diff --git a/build-tools-internal/src/main/resources/minimumGradleVersion b/build-tools-internal/src/main/resources/minimumGradleVersion index 631c6d36a93a4..83ea3179ddacc 100644 --- a/build-tools-internal/src/main/resources/minimumGradleVersion +++ b/build-tools-internal/src/main/resources/minimumGradleVersion @@ -1 +1 @@ -8.7 \ No newline at end of file +8.8 \ No newline at end of file diff --git a/build-tools/build.gradle b/build-tools/build.gradle index 900d1b54fe315..98fa8bb32ec82 100644 --- a/build-tools/build.gradle +++ b/build-tools/build.gradle @@ -6,6 +6,15 @@ * Side Public License, v 1. */ +buildscript { + repositories { + maven { + url 'https://jitpack.io' + } + mavenCentral() + } +} + plugins { id 'java-gradle-plugin' id 'groovy' @@ -107,6 +116,9 @@ configurations { } repositories { + maven { + url 'https://jitpack.io' + } mavenCentral() gradlePluginPortal() } diff --git a/build-tools/settings.gradle b/build-tools/settings.gradle index 63d80efcd505e..7590b8b6b054e 100644 --- a/build-tools/settings.gradle +++ b/build-tools/settings.gradle @@ -17,4 +17,4 @@ dependencyResolutionManagement { from(files("../gradle/build.versions.toml")) } } -} \ No newline at end of file +} diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java b/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java index d08dc469e5ba5..2bc4aa1a1be36 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java @@ -14,7 +14,6 @@ import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Plugin; import org.gradle.api.Project; -import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.artifacts.repositories.IvyArtifactRepository; import org.gradle.api.artifacts.type.ArtifactTypeDefinition; @@ -22,7 +21,9 @@ import org.gradle.api.provider.Property; import org.gradle.api.provider.Provider; -import java.util.Comparator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import javax.inject.Inject; @@ -42,14 +43,17 @@ public class DistributionDownloadPlugin implements Plugin { private static final String DOWNLOAD_REPO_NAME = "elasticsearch-downloads"; private static final String SNAPSHOT_REPO_NAME = "elasticsearch-snapshots"; public static final String DISTRO_EXTRACTED_CONFIG_PREFIX = "es_distro_extracted_"; + public static final String DISTRO_CONFIG_PREFIX = "es_distro_file_"; + private final ObjectFactory objectFactory; private NamedDomainObjectContainer distributionsContainer; - private NamedDomainObjectContainer distributionsResolutionStrategiesContainer; + private List distributionsResolutionStrategies; private Property dockerAvailability; @Inject public DistributionDownloadPlugin(ObjectFactory objectFactory) { + this.objectFactory = objectFactory; this.dockerAvailability = objectFactory.property(Boolean.class).value(false); } @@ -64,42 +68,95 @@ public void apply(Project project) { transformSpec.getTo().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE); }); - ArtifactTypeDefinition tarArtifactTypeDefinition = project.getDependencies().getArtifactTypes().maybeCreate("tar.gz"); + var tarArtifactTypeDefinition = project.getDependencies().getArtifactTypes().maybeCreate("tar.gz"); project.getDependencies().registerTransform(SymbolicLinkPreservingUntarTransform.class, transformSpec -> { transformSpec.getFrom().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, tarArtifactTypeDefinition.getName()); transformSpec.getTo().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE); }); setupResolutionsContainer(project); - setupDistributionContainer(project, dockerAvailability); + setupDistributionContainer(project); setupDownloadServiceRepo(project); } - private void setupDistributionContainer(Project project, Property dockerAvailable) { + private void setupDistributionContainer(Project project) { distributionsContainer = project.container(ElasticsearchDistribution.class, name -> { - Configuration fileConfiguration = project.getConfigurations().create("es_distro_file_" + name); - Configuration extractedConfiguration = project.getConfigurations().create(DISTRO_EXTRACTED_CONFIG_PREFIX + name); + var fileConfiguration = project.getConfigurations().create(DISTRO_CONFIG_PREFIX + name); + var extractedConfiguration = project.getConfigurations().create(DISTRO_EXTRACTED_CONFIG_PREFIX + name); extractedConfiguration.getAttributes() .attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE); - return new ElasticsearchDistribution( + + var distribution = new ElasticsearchDistribution( name, - project.getObjects(), + objectFactory, dockerAvailability, - fileConfiguration, - extractedConfiguration, - (dist) -> finalizeDistributionDependencies(project, dist) + objectFactory.fileCollection().from(fileConfiguration), + objectFactory.fileCollection().from(extractedConfiguration) ); + + registerDistributionDependencies(project, distribution); + return distribution; }); project.getExtensions().add(CONTAINER_NAME, distributionsContainer); } + private void registerDistributionDependencies(Project project, ElasticsearchDistribution distribution) { + project.getConfigurations() + .getByName(DISTRO_CONFIG_PREFIX + distribution.getName()) + .getDependencies() + .addLater( + project.provider(() -> distribution.maybeFreeze()) + .map( + frozenDistro -> project.getDependencies() + .create(resolveDependencyNotation(project, frozenDistro).getDefaultNotation()) + ) + ); + + project.getConfigurations() + .getByName(DISTRO_EXTRACTED_CONFIG_PREFIX + distribution.getName()) + .getDependencies() + .addAllLater( + project.provider(() -> distribution.maybeFreeze()) + .map( + frozenDistro -> distribution.getType().shouldExtract() + ? List.of( + project.getDependencies().create(resolveDependencyNotation(project, frozenDistro).getExtractedNotation()) + ) + : Collections.emptyList() + ) + ); + } + + private DistributionDependency resolveDependencyNotation(Project project, ElasticsearchDistribution distro) { + return distributionsResolutionStrategies.stream() + .map(r -> r.getResolver().resolve(project, distro)) + .filter(d -> d != null) + .findFirst() + .orElseGet(() -> DistributionDependency.of(dependencyNotation(distro))); + } + + /** + * Returns a dependency object representing the given distribution. + *

+ * The returned object is suitable to be passed to {@link DependencyHandler}. + * The concrete type of the object will be a set of maven coordinates as a {@link String}. + * Maven coordinates point to either the integ-test-zip coordinates on maven central, or a set of artificial + * coordinates that resolve to the Elastic download service through an ivy repository. + */ + private static String dependencyNotation(ElasticsearchDistribution distribution) { + if (distribution.getType() == ElasticsearchDistributionTypes.INTEG_TEST_ZIP) { + return "org.elasticsearch.distribution.integ-test-zip:elasticsearch:" + distribution.getVersion() + "@zip"; + } + var distroVersion = Version.fromString(distribution.getVersion()); + var extension = distribution.getType().getExtension(distribution.getPlatform()); + var classifier = distribution.getType().getClassifier(distribution.getPlatform(), distroVersion); + var group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP : FAKE_IVY_GROUP; + return group + ":elasticsearch" + ":" + distribution.getVersion() + classifier + "@" + extension; + } + private void setupResolutionsContainer(Project project) { - distributionsResolutionStrategiesContainer = project.container(DistributionResolution.class); - // We want this ordered in the same resolution strategies are added - distributionsResolutionStrategiesContainer.whenObjectAdded( - resolveDependencyNotation -> resolveDependencyNotation.setPriority(distributionsResolutionStrategiesContainer.size()) - ); - project.getExtensions().add(RESOLUTION_CONTAINER_NAME, distributionsResolutionStrategiesContainer); + distributionsResolutionStrategies = new ArrayList<>(); + project.getExtensions().add(RESOLUTION_CONTAINER_NAME, distributionsResolutionStrategies); } @SuppressWarnings("unchecked") @@ -108,30 +165,8 @@ public static NamedDomainObjectContainer getContainer } @SuppressWarnings("unchecked") - public static NamedDomainObjectContainer getRegistrationsContainer(Project project) { - return (NamedDomainObjectContainer) project.getExtensions().getByName(RESOLUTION_CONTAINER_NAME); - } - - private void finalizeDistributionDependencies(Project project, ElasticsearchDistribution distribution) { - DependencyHandler dependencies = project.getDependencies(); - // for the distribution as a file, just depend on the artifact directly - DistributionDependency distributionDependency = resolveDependencyNotation(project, distribution); - dependencies.add(distribution.configuration.getName(), distributionDependency.getDefaultNotation()); - // no extraction needed for rpm, deb or docker - if (distribution.getType().shouldExtract()) { - // The extracted configuration depends on the artifact directly but has - // an artifact transform registered to resolve it as an unpacked folder. - dependencies.add(distribution.getExtracted().getName(), distributionDependency.getExtractedNotation()); - } - } - - private DistributionDependency resolveDependencyNotation(Project p, ElasticsearchDistribution distribution) { - return distributionsResolutionStrategiesContainer.stream() - .sorted(Comparator.comparingInt(DistributionResolution::getPriority)) - .map(r -> r.getResolver().resolve(p, distribution)) - .filter(d -> d != null) - .findFirst() - .orElseGet(() -> DistributionDependency.of(dependencyNotation(distribution))); + public static List getRegistrationsContainer(Project project) { + return (List) project.getExtensions().getByName(RESOLUTION_CONTAINER_NAME); } private static void addIvyRepo(Project project, String name, String url, String group) { @@ -155,22 +190,4 @@ private static void setupDownloadServiceRepo(Project project) { addIvyRepo(project, SNAPSHOT_REPO_NAME, "https://snapshots-no-kpi.elastic.co", FAKE_SNAPSHOT_IVY_GROUP); } - /** - * Returns a dependency object representing the given distribution. - *

- * The returned object is suitable to be passed to {@link DependencyHandler}. - * The concrete type of the object will be a set of maven coordinates as a {@link String}. - * Maven coordinates point to either the integ-test-zip coordinates on maven central, or a set of artificial - * coordinates that resolve to the Elastic download service through an ivy repository. - */ - private String dependencyNotation(ElasticsearchDistribution distribution) { - if (distribution.getType() == ElasticsearchDistributionTypes.INTEG_TEST_ZIP) { - return "org.elasticsearch.distribution.integ-test-zip:elasticsearch:" + distribution.getVersion() + "@zip"; - } - Version distroVersion = Version.fromString(distribution.getVersion()); - String extension = distribution.getType().getExtension(distribution.getPlatform()); - String classifier = distribution.getType().getClassifier(distribution.getPlatform(), distroVersion); - String group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP : FAKE_IVY_GROUP; - return group + ":elasticsearch" + ":" + distribution.getVersion() + classifier + "@" + extension; - } } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/DistributionResolution.java b/build-tools/src/main/java/org/elasticsearch/gradle/DistributionResolution.java index 3b82c9f6975a0..0a63bdb22f96c 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/DistributionResolution.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/DistributionResolution.java @@ -15,6 +15,11 @@ public class DistributionResolution { private String name; private int priority; + public DistributionResolution(String name, Resolver resolver) { + this(name); + this.resolver = resolver; + } + public DistributionResolution(String name) { this.name = name; } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java b/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java index 5350b6698cb30..afb90ba1ca62e 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java @@ -9,9 +9,9 @@ package org.elasticsearch.gradle; import org.elasticsearch.gradle.distribution.ElasticsearchDistributionTypes; -import org.gradle.api.Action; import org.gradle.api.Buildable; -import org.gradle.api.artifacts.Configuration; +import org.gradle.api.file.ConfigurableFileCollection; +import org.gradle.api.file.FileCollection; import org.gradle.api.model.ObjectFactory; import org.gradle.api.provider.Property; import org.gradle.api.tasks.TaskDependency; @@ -44,7 +44,7 @@ public String toString() { private final String name; private final Property dockerAvailability; // pkg private so plugin can configure - final Configuration configuration; + final FileCollection configuration; private final Property architecture; private final Property version; @@ -52,17 +52,16 @@ public String toString() { private final Property platform; private final Property bundledJdk; private final Property failIfUnavailable; - private final Configuration extracted; - private Action distributionFinalizer; + private final Property preferArchive; + private final ConfigurableFileCollection extracted; private boolean frozen = false; ElasticsearchDistribution( String name, ObjectFactory objectFactory, Property dockerAvailability, - Configuration fileConfiguration, - Configuration extractedConfiguration, - Action distributionFinalizer + ConfigurableFileCollection fileConfiguration, + ConfigurableFileCollection extractedConfiguration ) { this.name = name; this.dockerAvailability = dockerAvailability; @@ -74,8 +73,8 @@ public String toString() { this.platform = objectFactory.property(Platform.class); this.bundledJdk = objectFactory.property(Boolean.class); this.failIfUnavailable = objectFactory.property(Boolean.class).convention(true); + this.preferArchive = objectFactory.property(Boolean.class).convention(false); this.extracted = extractedConfiguration; - this.distributionFinalizer = distributionFinalizer; } public String getName() { @@ -140,6 +139,14 @@ public void setFailIfUnavailable(boolean failIfUnavailable) { this.failIfUnavailable.set(failIfUnavailable); } + public boolean getPreferArchive() { + return preferArchive.get(); + } + + public void setPreferArchive(boolean preferArchive) { + this.preferArchive.set(preferArchive); + } + public void setArchitecture(Architecture architecture) { this.architecture.set(architecture); } @@ -161,7 +168,6 @@ public String toString() { public ElasticsearchDistribution maybeFreeze() { if (frozen == false) { finalizeValues(); - distributionFinalizer.execute(this); frozen = true; } return this; @@ -172,7 +178,7 @@ public String getFilepath() { return configuration.getSingleFile().toString(); } - public Configuration getExtracted() { + public ConfigurableFileCollection getExtracted() { if (getType().shouldExtract() == false) { throw new UnsupportedOperationException( "distribution type [" + getType().getName() + "] for " + "elasticsearch distribution [" + name + "] cannot be extracted" @@ -187,7 +193,9 @@ public TaskDependency getBuildDependencies() { return task -> Collections.emptySet(); } else { maybeFreeze(); - return getType().shouldExtract() ? extracted.getBuildDependencies() : configuration.getBuildDependencies(); + return getType().shouldExtract() && (preferArchive.get() == false) + ? extracted.getBuildDependencies() + : configuration.getBuildDependencies(); } } @@ -252,13 +260,4 @@ void finalizeValues() { type.finalizeValue(); bundledJdk.finalizeValue(); } - - public TaskDependency getArchiveDependencies() { - if (skippingDockerDistributionBuild()) { - return task -> Collections.emptySet(); - } else { - maybeFreeze(); - return configuration.getBuildDependencies(); - } - } } diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java index 8229821754198..ad41c3a867862 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java @@ -245,14 +245,12 @@ public void setVersions(List versions) { private void doSetVersion(String version) { String distroName = "testclusters" + path.replace(":", "-") + "-" + this.name + "-" + version; NamedDomainObjectContainer container = DistributionDownloadPlugin.getContainer(project); - if (container.findByName(distroName) == null) { - container.create(distroName); - } - ElasticsearchDistribution distro = container.getByName(distroName); - distro.setVersion(version); - distro.setArchitecture(Architecture.current()); - setDistributionType(distro, testDistribution); - distributions.add(distro); + // TODO Refactor test using register<> for reducing overhead + ElasticsearchDistribution distribution = container.maybeCreate(distroName); + distribution.setVersion(version); + distribution.setArchitecture(Architecture.current()); + setDistributionType(distribution, testDistribution); + distributions.add(distribution); } @Internal diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java b/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java index 3bf3dafc97b3c..4e0e26b1d275d 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java @@ -16,6 +16,7 @@ import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.ModuleDependency; import org.gradle.api.artifacts.ProjectDependency; +import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginExtension; @@ -183,14 +184,11 @@ public static void extendSourceSet(Project project, String parentSourceSetName, } } - public static Dependency projectDependency(Project project, String projectPath, String projectConfig) { - if (project.findProject(projectPath) == null) { - throw new GradleException("no project [" + projectPath + "], project names: " + project.getRootProject().getAllprojects()); - } + private static Dependency projectDependency(DependencyHandler dependencyHandler, String projectPath, String projectConfig) { Map depConfig = new HashMap<>(); depConfig.put("path", projectPath); depConfig.put("configuration", projectConfig); - return project.getDependencies().project(depConfig); + return dependencyHandler.project(depConfig); } /** diff --git a/build.gradle b/build.gradle index 79a7ea5655757..b9f634dbfaf35 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,16 @@ import org.elasticsearch.gradle.internal.ResolveAllDependencies import java.nio.file.Files import static java.nio.file.StandardCopyOption.REPLACE_EXISTING +buildscript { + repositories { + maven { + url 'https://jitpack.io' + } + + mavenCentral() + } +} + plugins { id 'lifecycle-base' id 'elasticsearch.docker-support' @@ -313,7 +323,7 @@ allprojects { integTestTask.mustRunAfter tasks.matching { it.name.equals("test") } } - configurations.matching { it.canBeResolved }.all { Configuration configuration -> +/* configurations.matching { it.canBeResolved }.all { Configuration configuration -> dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep -> Project upstreamProject = dep.dependencyProject if (project.path != upstreamProject?.path) { @@ -324,7 +334,7 @@ allprojects { } } } - } + }*/ } apply plugin: 'elasticsearch.formatting' diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index 9eb5033bb4122..b6862d42463cb 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -18,11 +18,17 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla with libFiles(oss) } into('config') { - dirMode 0750 - fileMode 0660 + dirPermissions { + unix 0750 + } + filePermissions { + unix 0660 + } with configFiles(distributionType, oss, jdk) from { - dirMode 0750 + dirPermissions { + unix 0750 + } jvmOptionsDir.getParent() } } @@ -36,21 +42,31 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla } into('') { from { - dirMode 0755 + dirPermissions { + unix 0755 + } logsDir.getParent() } } into('') { from { - dirMode 0755 + dirPermissions { + unix 0755 + } pluginsDir.getParent() } } from(rootProject.projectDir) { + filePermissions { + unix(0644) + } include 'README.asciidoc' } from(rootProject.file('licenses')) { include oss ? 'SSPL-1.0+ELASTIC-LICENSE-2.0.txt' : 'ELASTIC-LICENSE-2.0.txt' + filePermissions { + unix(0644) + } rename { 'LICENSE.txt' } } diff --git a/distribution/build.gradle b/distribution/build.gradle index 6424872503ca0..7c755df927855 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -345,9 +345,9 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { if (it.relativePath.segments[-2] == 'bin' || ((platform == 'darwin-x86_64' || platform == 'darwin-aarch64') && it.relativePath.segments[-2] == 'MacOS')) { // bin files, wherever they are within modules (eg platform specific) should be executable // and MacOS is an alternative to bin on macOS - it.mode = 0755 + it.permissions.unix(0755) } else { - it.mode = 0644 + it.permissions.unix(0644) } } List excludePlatforms = ['linux-x86_64', 'linux-aarch64', 'windows-x86_64', 'darwin-x86_64', 'darwin-aarch64'] @@ -398,7 +398,11 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { from '../src/bin' exclude '*.exe' exclude '*.bat' - eachFile { it.setMode(0755) } + eachFile { + it.permissions{ + unix(0755) + } + } filter("tokens" : expansionsForDistribution(distributionType, testDistro, jdk), ReplaceTokens.class) } // windows files, only for zip @@ -416,7 +420,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { } // module provided bin files with copySpec { - eachFile { it.setMode(0755) } + eachFile { it.permissions.unix(0755) } from(testDistro ? integTestBinFiles : defaultBinFiles) if (distributionType != 'zip') { exclude '*.bat' @@ -432,11 +436,15 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { } else { if (jdk) { from(buildDefaultNoticeTaskProvider) { - fileMode = 0644 + filePermissions { + unix(0644) + } } } else { from(buildDefaultNoJdkNoticeTaskProvider) { - fileMode = 0644 + filePermissions { + unix(0644) + } } } } @@ -456,7 +464,13 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { } eachFile { FileCopyDetails details -> if (details.relativePath.segments[-2] == 'bin' || details.relativePath.segments[-1] == 'jspawnhelper') { - details.mode = 0755 + details.permissions { + unix(0755) + } + } else { + details.permissions { + unix(0644) + } } if (details.name == 'src.zip') { details.exclude() diff --git a/distribution/packages/build.gradle b/distribution/packages/build.gradle index 5da8d49dbdb96..389333197d4b9 100644 --- a/distribution/packages/build.gradle +++ b/distribution/packages/build.gradle @@ -42,23 +42,13 @@ import java.util.regex.Pattern * dpkg -c path/to/elasticsearch.deb */ -buildscript { - repositories { - maven { - url 'https://jitpack.io' - } - mavenCentral() - } - dependencies { - classpath "com.github.breskeby:gradle-ospackage-plugin:2da19425133" - } +plugins { + id "com.netflix.nebula.ospackage-base" version "11.9.1" } -apply plugin: "com.netflix.nebula.ospackage-base" void addProcessFilesTask(String type, boolean oss, boolean jdk) { String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}" - String taskName = "process${oss ? 'Oss' : ''}${jdk ? '' : 'NoJdk'}${type.capitalize()}Files" tasks.register(taskName, Copy) { into packagingFiles @@ -147,7 +137,9 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit } from(rootProject.projectDir) { include 'README.asciidoc' - fileMode 0644 + filePermissions { + unix 0644 + } } into('lib') { with libFiles(oss) @@ -170,9 +162,13 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit directory('/' + segments[0..i].join('/'), 0755) } if (segments[-2] == 'bin' || segments[-1] == 'jspawnhelper') { - fcp.mode = 0755 + fcp.permissions { + unix(0755) + } } else { - fcp.mode = 0644 + fcp.permissions { + unix(0644) + } } } } @@ -182,7 +178,9 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit if (type == 'deb') { into("/usr/share/doc/${packageName}") { from "${packagingFiles}/copyright" - fileMode 0644 + filePermissions { + unix(0644) + } } } else { assert type == 'rpm' @@ -191,7 +189,9 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit include oss ? 'SSPL-1.0+ELASTIC-LICENSE-2.0.txt' : 'ELASTIC-LICENSE-2.0.txt' rename { 'LICENSE.txt' } } - fileMode 0644 + filePermissions { + unix(0644) + } } } @@ -207,7 +207,9 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit configurationFile '/etc/elasticsearch/users_roles' } from("${packagingFiles}") { - dirMode 02750 + dirPermissions { + unix(02750) + } into('/etc') permissionGroup 'elasticsearch' setgid true @@ -218,9 +220,13 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit } from("${packagingFiles}/etc/elasticsearch") { into('/etc/elasticsearch') - dirMode 02750 + dirPermissions { + unix(02750) + } setgid = true - fileMode 0660 + filePermissions { + unix(0660) + } permissionGroup 'elasticsearch' includeEmptyDirs true createDirectoryEntry true @@ -231,34 +237,46 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit into(new File(envFile).getParent()) { fileType CONFIG | NOREPLACE permissionGroup 'elasticsearch' - fileMode 0660 + filePermissions { + unix(0660) + } from "${packagingFiles}/env/elasticsearch" } // ========= systemd ========= into('/usr/lib/tmpfiles.d') { from "${packagingFiles}/systemd/elasticsearch.conf" - fileMode 0644 + filePermissions { + unix(0644) + } } into('/usr/lib/systemd/system') { fileType CONFIG | NOREPLACE from "${packagingFiles}/systemd/elasticsearch.service" - fileMode 0644 + filePermissions { + unix(0644) + } } into('/usr/lib/sysctl.d') { fileType CONFIG | NOREPLACE from "${packagingFiles}/systemd/sysctl/elasticsearch.conf" - fileMode 0644 + filePermissions { + unix(0644) + } } into('/usr/share/elasticsearch/bin') { from "${packagingFiles}/systemd/systemd-entrypoint" - fileMode 0755 + filePermissions { + unix(0755) + } } // ========= sysV init ========= configurationFile '/etc/init.d/elasticsearch' into('/etc/init.d') { - fileMode 0750 + filePermissions { + unix(0750) + } fileType CONFIG | NOREPLACE from "${packagingFiles}/init.d/elasticsearch" } @@ -274,7 +292,9 @@ Closure commonPackageConfig(String type, boolean oss, boolean jdk, String archit createDirectoryEntry true user u permissionGroup g - dirMode mode + dirPermissions { + unix(mode) + } setgid (mode == 02750) } } @@ -348,7 +368,9 @@ Closure commonDebConfig(boolean oss, boolean jdk, String architecture) { if (oss) { rename('elasticsearch', 'elasticsearch-oss') } - fileMode 0644 + filePermissions { + unix(0644) + } } } } diff --git a/gradle/build.versions.toml b/gradle/build.versions.toml index f2321138c00cd..a8d3fe220073a 100644 --- a/gradle/build.versions.toml +++ b/gradle/build.versions.toml @@ -33,7 +33,8 @@ junit5-vintage = { group = "org.junit.vintage", name="junit-vintage-engine", ver maven-model = "org.apache.maven:maven-model:3.6.2" mockito-core = "org.mockito:mockito-core:1.9.5" nebula-info = "com.netflix.nebula:gradle-info-plugin:11.3.3" -shadow-plugin = "com.github.johnrengelman:shadow:8.1.1" +reflections = "org.reflections:reflections:0.9.12" +shadow-plugin = "com.github.breskeby:shadow:3b035f2" spock-core = { group = "org.spockframework", name="spock-core", version.ref="spock" } spock-junit4 = { group = "org.spockframework", name="spock-junit4", version.ref="spock" } spock-platform = { group = "org.spockframework", name="spock-bom", version.ref="spock" } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index c3f4f4c9143e6..13b6f4635265e 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -394,9 +394,14 @@ - - - + + + + + + + + @@ -824,11 +829,6 @@ - - - - - @@ -974,14 +974,9 @@ - - - - - - - - + + + @@ -4055,6 +4050,11 @@ + + + + + @@ -4100,6 +4100,11 @@ + + + + + @@ -4135,6 +4140,11 @@ + + + + + @@ -4205,6 +4215,16 @@ + + + + + + + + + + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fcbbad6dd644c..515ab9d5f1822 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=194717442575a6f96e1c1befa2c30e9a4fc90f701d7aee33eb879b79e7ff05c0 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionSha256Sum=f8b4f4772d302c8ff580bc40d0f56e715de69b163546944f787c87abf209c961 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4269074..b740cf13397ab 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/plugins/examples/gradle/wrapper/gradle-wrapper.properties b/plugins/examples/gradle/wrapper/gradle-wrapper.properties index fcbbad6dd644c..515ab9d5f1822 100644 --- a/plugins/examples/gradle/wrapper/gradle-wrapper.properties +++ b/plugins/examples/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=194717442575a6f96e1c1befa2c30e9a4fc90f701d7aee33eb879b79e7ff05c0 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionSha256Sum=f8b4f4772d302c8ff580bc40d0f56e715de69b163546944f787c87abf209c961 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/server/build.gradle b/server/build.gradle index c06f64ad6591e..a38803877984c 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -250,12 +250,12 @@ tasks.named("thirdPartyAudit").configure { tasks.named("dependencyLicenses").configure { mapping from: /lucene-.*/, to: 'lucene' - dependencies = project.configurations.runtimeClasspath.fileCollection { - it.group.startsWith('org.elasticsearch') == false || - // keep the following org.elasticsearch jars in - (it.name == 'jna' || - it.name == 'securesm') - } + + configureDependencies( + project.configurations.runtimeClasspath, project.configurations.resolveableCompileOnly, identifier -> { + return identifier instanceof ModuleComponentIdentifier + (identifier.moduleIdentifier.name == 'jna' || identifier.moduleIdentifier.name == 'securesm') + }) } tasks.named("licenseHeaders").configure { diff --git a/settings.gradle b/settings.gradle index 2cbe2f841daf2..980a839f78192 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,6 +4,9 @@ import org.elasticsearch.gradle.internal.toolchain.AdoptiumJdkToolchainResolver pluginManagement { repositories { + maven { + url 'https://jitpack.io' + } mavenCentral() gradlePluginPortal() }