From 4642eeff72892747ef086516bf474ba86381bc5d Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Thu, 9 Oct 2025 21:14:04 +0200 Subject: [PATCH] Fix dependency reporting (#136209) This has been broken since 9.0.3. likely due to some swallowed api change in Gradle. This fixes and adds test coverage to dependency reporting used in DRA artifacts building Fix interdependency to Licenses task (cherry picked from commit f74406d4b1c94db769a0260f0918eb8be0bf4146) # Conflicts: # build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/util/DependenciesUtils.java # modules/repository-s3/build.gradle # plugins/discovery-ec2/build.gradle # x-pack/plugin/core/build.gradle # x-pack/plugin/identity-provider/build.gradle --- .../internal/BuildPluginFuncTest.groovy | 25 ++++++++++- .../internal/AbstractDependenciesTask.java | 44 +++++++++++++++++++ .../internal/DependenciesInfoPlugin.java | 7 +-- .../gradle/internal/DependenciesInfoTask.java | 25 +++++------ .../precommit/DependencyLicensesTask.java | 37 ++-------------- .../internal/util/DependenciesUtils.java | 11 ++++- client/sniffer/build.gradle | 3 +- distribution/build.gradle | 5 +++ modules/ingest-geoip/build.gradle | 6 ++- modules/repository-s3/build.gradle | 34 ++++++++++++++ plugins/analysis-ukrainian/build.gradle | 4 +- plugins/discovery-ec2/build.gradle | 7 ++- .../es-opensaml-security-api/build.gradle | 4 +- x-pack/plugin/core/build.gradle | 3 +- x-pack/plugin/identity-provider/build.gradle | 11 ++++- x-pack/plugin/inference/build.gradle | 4 +- x-pack/plugin/security/build.gradle | 4 +- 17 files changed, 172 insertions(+), 62 deletions(-) create mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/AbstractDependenciesTask.java diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy index cf03bc8019114..041c312ae8287 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy @@ -151,7 +151,11 @@ class BuildPluginFuncTest extends AbstractGradleFuncTest { tasks.named('checkstyleMain').configure { enabled = false } tasks.named('loggerUsageCheck').configure { enabled = false } // tested elsewhere - tasks.named('thirdPartyAudit').configure { enabled = false } + tasks.named('thirdPartyAudit').configure { + getRuntimeJavaVersion().set(JavaVersion.VERSION_21) + getTargetCompatibility().set(JavaVersion.VERSION_21) + enabled = false + } """ when: def result = gradleRunner("check").build() @@ -167,6 +171,25 @@ class BuildPluginFuncTest extends AbstractGradleFuncTest { result.task(":loggerUsageCheck").outcome == TaskOutcome.SKIPPED } + def "can generate dependency infos file"() { + given: + repository.generateJar("junit", "junit", "4.12", 'org.acme.JunitMock') + repository.configureBuild(buildFile) + file("licenses/junit-4.12.jar.sha1").text = "2973d150c0dc1fefe998f834810d68f278ea58ec" + file("licenses/junit-LICENSE.txt").text = EXAMPLE_LICENSE + file("licenses/junit-NOTICE.txt").text = "mock notice" + buildFile << """ + dependencies { + api "junit:junit:4.12" + } + """ + when: + def result = gradleRunner("dependenciesInfo").build() + then: + result.task(":dependenciesInfo").outcome == TaskOutcome.SUCCESS + file("build/reports/dependencies/dependencies.csv").text == "junit:junit,4.12,https://repo1.maven.org/maven2/junit/junit/4.12,BSD-3-Clause,\n" + } + def assertValidJar(File jar) { try (ZipFile zipFile = new ZipFile(jar)) { ZipEntry licenseEntry = zipFile.getEntry("META-INF/LICENSE.txt") diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/AbstractDependenciesTask.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/AbstractDependenciesTask.java new file mode 100644 index 0000000000000..141ea7ed5d6a7 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/AbstractDependenciesTask.java @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.gradle.internal; + +import org.gradle.api.DefaultTask; +import org.gradle.api.InvalidUserDataException; +import org.gradle.api.provider.MapProperty; +import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Optional; + +import java.util.Map; + +public abstract class AbstractDependenciesTask extends DefaultTask { + + @Input + @Optional + public abstract MapProperty getMappings(); + + /** + * Add a mapping from a regex pattern for the jar name, to a prefix to find + * the LICENSE and NOTICE file for that jar. + */ + public void mapping(Map props) { + String from = props.get("from"); + if (from == null) { + throw new InvalidUserDataException("Missing \"from\" setting for license name mapping"); + } + String to = props.get("to"); + if (to == null) { + throw new InvalidUserDataException("Missing \"to\" setting for license name mapping"); + } + if (props.size() > 2) { + throw new InvalidUserDataException("Unknown properties for mapping on dependencyLicenses: " + props.keySet()); + } + getMappings().put(from, to); + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoPlugin.java index 669d1b5078dab..9e45ec978be8c 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoPlugin.java @@ -17,6 +17,8 @@ import org.gradle.api.attributes.Usage; import org.gradle.api.plugins.JavaPlugin; +import static org.elasticsearch.gradle.internal.util.DependenciesUtils.createNonTransitiveArtifactsView; + public class DependenciesInfoPlugin implements Plugin { public static String USAGE_ATTRIBUTE = "DependenciesInfo"; @@ -25,16 +27,15 @@ public class DependenciesInfoPlugin implements Plugin { public void apply(final Project project) { project.getPlugins().apply(CompileOnlyResolvePlugin.class); var depsInfo = project.getTasks().register("dependenciesInfo", DependenciesInfoTask.class); - depsInfo.configure(t -> { var runtimeConfiguration = project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME); - t.getRuntimeArtifacts().set(project.getProviders().provider(() -> runtimeConfiguration.getIncoming().getArtifacts())); + t.getRuntimeArtifacts() + .set(project.getProviders().provider(() -> createNonTransitiveArtifactsView(runtimeConfiguration).getArtifacts())); t.getClasspath().from(runtimeConfiguration); var compileOnlyConfiguration = project.getConfigurations() .getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME); t.getCompileOnlyArtifacts().set(project.getProviders().provider(() -> compileOnlyConfiguration.getIncoming().getArtifacts())); t.getClasspath().from(compileOnlyConfiguration); - }); Configuration dependenciesInfoFilesConfiguration = project.getConfigurations().create("dependenciesInfoFiles"); dependenciesInfoFilesConfiguration.setCanBeResolved(false); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoTask.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoTask.java index 180c1308d07be..d974200ff94cb 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoTask.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoTask.java @@ -17,19 +17,21 @@ import org.gradle.api.file.ConfigurableFileCollection; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.ProjectLayout; -import org.gradle.api.internal.ConventionTask; import org.gradle.api.model.ObjectFactory; -import org.gradle.api.provider.MapProperty; import org.gradle.api.provider.Property; import org.gradle.api.provider.Provider; import org.gradle.api.provider.ProviderFactory; +import org.gradle.api.tasks.CacheableTask; +import org.gradle.api.tasks.Classpath; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.InputDirectory; -import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.OutputFile; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; +import org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier; import java.io.File; import java.io.IOException; @@ -55,7 +57,8 @@ *
  • license: SPDX license identifier, custom license or UNKNOWN.
  • * */ -public abstract class DependenciesInfoTask extends ConventionTask { +@CacheableTask +public abstract class DependenciesInfoTask extends AbstractDependenciesTask { @Inject public abstract ProviderFactory getProviderFactory(); @@ -86,7 +89,7 @@ public Provider> getCompileOnlyModules() { * artifact transforms that might be applied and fail due to missing task dependency to jar * generating tasks. * */ - @InputFiles + @Classpath abstract ConfigurableFileCollection getClasspath(); private Provider> mapToModuleComponentIdentifiers(ArtifactCollection artifacts) { @@ -94,8 +97,9 @@ private Provider> mapToModuleComponentIdentifiers () -> artifacts.getArtifacts() .stream() .map(r -> r.getId()) - .filter(id -> id instanceof ModuleComponentIdentifier) - .map(id -> (ModuleComponentIdentifier) id) + .filter(mcaId -> mcaId instanceof ModuleComponentArtifactIdentifier) + .map(mcaId -> (ModuleComponentArtifactIdentifier) mcaId) + .map(it -> it.getComponentIdentifier()) .collect(Collectors.toSet()) ); } @@ -111,6 +115,7 @@ private Provider> mapToModuleComponentIdentifiers * Directory to read license files */ @Optional + @PathSensitive(PathSensitivity.RELATIVE) @InputDirectory public File getLicensesDir() { File asFile = licensesDir.get().getAsFile(); @@ -143,7 +148,6 @@ public DependenciesInfoTask(ProjectLayout projectLayout, ObjectFactory objectFac @TaskAction public void generateDependenciesInfo() throws IOException { - final Set compileOnlyIds = getCompileOnlyModules().map( set -> set.stream() .map(id -> id.getModuleIdentifier().getGroup() + ":" + id.getModuleIdentifier().getName() + ":" + id.getVersion()) @@ -166,7 +170,6 @@ public void generateDependenciesInfo() throws IOException { final String url = createURL(dep.getGroup(), moduleName, dep.getVersion()); final String dependencyName = DependencyLicensesTask.getDependencyName(mappings, moduleName); getLogger().info("mapped dependency " + dep.getGroup() + ":" + moduleName + " to " + dependencyName + " for license info"); - final String licenseType = getLicenseType(dep.getGroup(), dependencyName); output.append(dep.getGroup() + ":" + moduleName + "," + dep.getVersion() + "," + url + "," + licenseType + "\n"); } @@ -174,10 +177,6 @@ public void generateDependenciesInfo() throws IOException { Files.write(outputFile.toPath(), output.toString().getBytes("UTF-8"), StandardOpenOption.CREATE); } - @Input - @Optional - public abstract MapProperty getMappings(); - /** * Create an URL on Maven Central * based on dependency coordinates. 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 e9efee4fa157d..75ae9997bda4d 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 @@ -8,10 +8,9 @@ */ package org.elasticsearch.gradle.internal.precommit; +import org.elasticsearch.gradle.internal.AbstractDependenciesTask; import org.elasticsearch.gradle.internal.precommit.LicenseAnalyzer.LicenseInfo; -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; @@ -39,7 +38,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -94,7 +92,7 @@ * comply with the license terms. */ @CacheableTask -public abstract class DependencyLicensesTask extends DefaultTask { +public abstract class DependencyLicensesTask extends AbstractDependenciesTask { private final Pattern regex = Pattern.compile("-v?\\d+.*"); @@ -112,11 +110,6 @@ public abstract class DependencyLicensesTask extends DefaultTask { */ private final DirectoryProperty licensesDir; - /** - * A map of patterns to prefix, used to find the LICENSE and NOTICE file. - */ - private Map mappings = new LinkedHashMap<>(); - /** * Names of dependencies whose shas should not exist. */ @@ -128,25 +121,6 @@ public abstract class DependencyLicensesTask extends DefaultTask { private LinkedHashSet ignoreFiles = new LinkedHashSet<>(); private ProjectLayout projectLayout; - /** - * Add a mapping from a regex pattern for the jar name, to a prefix to find - * the LICENSE and NOTICE file for that jar. - */ - public void mapping(Map props) { - String from = props.get("from"); - if (from == null) { - throw new InvalidUserDataException("Missing \"from\" setting for license name mapping"); - } - String to = props.get("to"); - if (to == null) { - throw new InvalidUserDataException("Missing \"to\" setting for license name mapping"); - } - if (props.size() > 2) { - throw new InvalidUserDataException("Unknown properties for mapping on dependencyLicenses: " + props.keySet()); - } - mappings.put(from, to); - } - @Inject public DependencyLicensesTask(ObjectFactory objects, ProjectLayout projectLayout) { this.projectLayout = projectLayout; @@ -267,7 +241,7 @@ private void checkDependencies(Map licenses, Map getIgnoreFiles() { return new LinkedHashSet<>(ignoreFiles); } - @Input - public LinkedHashMap getMappings() { - return new LinkedHashMap<>(mappings); - } - /** * Convencience method for configuring dependencies to be checked and ignoring transitive dependencies for now. * */ 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 index 8770046b78c8b..b99af2a557acc 100644 --- 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 @@ -9,6 +9,7 @@ package org.elasticsearch.gradle.internal.util; +import org.gradle.api.artifacts.ArtifactView; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.ResolvableDependencies; import org.gradle.api.artifacts.component.ComponentIdentifier; @@ -27,6 +28,14 @@ public static FileCollection createFileCollectionFromNonTransitiveArtifactsView( Configuration configuration, Spec componentFilter ) { + return createNonTransitiveArtifactsView(configuration, componentFilter).getFiles(); + } + + public static ArtifactView createNonTransitiveArtifactsView(Configuration configuration) { + return createNonTransitiveArtifactsView(configuration, identifier -> true); + } + + public static ArtifactView createNonTransitiveArtifactsView(Configuration configuration, Spec componentFilter) { ResolvableDependencies incoming = configuration.getIncoming(); return incoming.artifactView(viewConfiguration -> { Set firstLevelDependencyComponents = incoming.getResolutionResult() @@ -44,6 +53,6 @@ public static FileCollection createFileCollectionFromNonTransitiveArtifactsView( viewConfiguration.componentFilter( new AndSpec<>(identifier -> firstLevelDependencyComponents.contains(identifier), componentFilter) ); - }).getFiles(); + }); } } diff --git a/client/sniffer/build.gradle b/client/sniffer/build.gradle index 38fc949a5c7c8..0c3e044f239e6 100644 --- a/client/sniffer/build.gradle +++ b/client/sniffer/build.gradle @@ -17,6 +17,7 @@ * under the License. */ import org.elasticsearch.gradle.internal.conventions.precommit.LicenseHeadersTask +import org.elasticsearch.gradle.internal.AbstractDependenciesTask apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.publish' @@ -67,7 +68,7 @@ tasks.named('forbiddenApisTest').configure { replaceSignatureFiles 'jdk-signatures' } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /http.*/, to: 'httpclient' mapping from: /commons-.*/, to: 'commons' } diff --git a/distribution/build.gradle b/distribution/build.gradle index 63cdcbff5f0fa..917c1032d3c78 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -83,6 +83,11 @@ tasks.register("generateDependenciesReport", ConcatFilesTask) { 'https://oss-dependencies.elastic.co/red-hat-universal-base-image-minimal/8/ubi-minimal-8-source.tar.gz' ] additionalLines << rhelUbiFields.join(',') + doLast { + if(target.text.readLines().size() < 100) { + throw new GradleException("Suspiciously low number of dependencies. Double check.") + } + } } /***************************************************************************** diff --git a/modules/ingest-geoip/build.gradle b/modules/ingest-geoip/build.gradle index 0e3f597ce9767..65f0c51590d31 100644 --- a/modules/ingest-geoip/build.gradle +++ b/modules/ingest-geoip/build.gradle @@ -8,6 +8,7 @@ */ import org.elasticsearch.gradle.OS +import org.elasticsearch.gradle.internal.AbstractDependenciesTask apply plugin: 'elasticsearch.internal-yaml-rest-test' apply plugin: 'elasticsearch.yaml-rest-compat-test' @@ -78,10 +79,13 @@ tasks.named("forbiddenPatterns").configure { exclude '**/*.mmdb' } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /geoip.*/, to: 'maxmind-geolite2-eula' mapping from: /maxmind-db.*/, to: 'maxmind-db-reader' mapping from: /jackson.*/, to: 'jackson' +} + +tasks.named("dependencyLicenses").configure { ignoreFile 'elastic-geoip-database-service-agreement-LICENSE.txt' } diff --git a/modules/repository-s3/build.gradle b/modules/repository-s3/build.gradle index 5664fb6272e49..551052b171aa4 100644 --- a/modules/repository-s3/build.gradle +++ b/modules/repository-s3/build.gradle @@ -10,6 +10,8 @@ import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ +import org.elasticsearch.gradle.internal.AbstractDependenciesTask + apply plugin: 'elasticsearch.internal-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.internal-java-rest-test' @@ -68,11 +70,43 @@ restResources { } } +<<<<<<< HEAD tasks.named("dependencyLicenses").configure { mapping from: /aws-java-sdk-.*/, to: 'aws-java-sdk' mapping from: /jmespath-java.*/, to: 'aws-java-sdk' mapping from: /jackson-.*/, to: 'jackson' mapping from: /jaxb-.*/, to: 'jaxb' +======= +tasks.withType(AbstractDependenciesTask).configureEach { + mapping from: 'annotations', to: 'aws-sdk-2' + mapping from: 'apache-client', to: 'aws-sdk-2' + mapping from: 'arns', to: 'aws-sdk-2' + mapping from: 'auth', to: 'aws-sdk-2' + mapping from: 'aws-core', to: 'aws-sdk-2' + mapping from: 'aws-query-protocol', to: 'aws-sdk-2' + mapping from: 'aws-xml-protocol', to: 'aws-sdk-2' + mapping from: 'checksums', to: 'aws-sdk-2' + mapping from: 'checksums-spi', to: 'aws-sdk-2' + mapping from: 'endpoints-spi', to: 'aws-sdk-2' + mapping from: 'http-auth', to: 'aws-sdk-2' + mapping from: 'http-auth-aws', to: 'aws-sdk-2' + mapping from: 'http-auth-spi', to: 'aws-sdk-2' + mapping from: 'http-client-spi', to: 'aws-sdk-2' + mapping from: 'identity-spi', to: 'aws-sdk-2' + mapping from: 'json-utils', to: 'aws-sdk-2' + mapping from: 'metrics-spi', to: 'aws-sdk-2' + mapping from: 'profiles', to: 'aws-sdk-2' + mapping from: 'protocol-core', to: 'aws-sdk-2' + mapping from: 'regions', to: 'aws-sdk-2' + mapping from: 'retries', to: 'aws-sdk-2' + mapping from: 'retries-spi', to: 'aws-sdk-2' + mapping from: 's3', to: 'aws-sdk-2' + mapping from: 'sdk-core', to: 'aws-sdk-2' + mapping from: 'services', to: 'aws-sdk-2' + mapping from: 'sts', to: 'aws-sdk-2' + mapping from: 'third-party-jackson-core', to: 'aws-sdk-2' + mapping from: 'utils', to: 'aws-sdk-2' +>>>>>>> f74406d4b1c9 (Fix dependency reporting (#136209)) } esplugin.bundleSpec.from('config/repository-s3') { diff --git a/plugins/analysis-ukrainian/build.gradle b/plugins/analysis-ukrainian/build.gradle index a6414ae673e2c..b30e18ab578dd 100644 --- a/plugins/analysis-ukrainian/build.gradle +++ b/plugins/analysis-ukrainian/build.gradle @@ -6,6 +6,8 @@ * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ +import org.elasticsearch.gradle.internal.AbstractDependenciesTask + apply plugin: 'elasticsearch.internal-yaml-rest-test' apply plugin: 'elasticsearch.yaml-rest-compat-test' @@ -27,7 +29,7 @@ restResources { } } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /lucene-.*/, to: 'lucene' mapping from: /morfologik-.*/, to: 'lucene' } diff --git a/plugins/discovery-ec2/build.gradle b/plugins/discovery-ec2/build.gradle index e1765fb256c8d..7b9b7fd1c5548 100644 --- a/plugins/discovery-ec2/build.gradle +++ b/plugins/discovery-ec2/build.gradle @@ -1,4 +1,3 @@ -import org.elasticsearch.gradle.internal.info.BuildParams /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one @@ -8,6 +7,10 @@ import org.elasticsearch.gradle.internal.info.BuildParams * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ + +import org.elasticsearch.gradle.internal.AbstractDependenciesTask +import org.elasticsearch.gradle.internal.info.BuildParams + apply plugin: 'elasticsearch.internal-java-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' @@ -38,7 +41,7 @@ dependencies { internalClusterTestImplementation project(':test:fixtures:ec2-imds-fixture') } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /aws-java-sdk-.*/, to: 'aws-java-sdk' mapping from: /jackson-.*/, to: 'jackson' } diff --git a/x-pack/libs/es-opensaml-security-api/build.gradle b/x-pack/libs/es-opensaml-security-api/build.gradle index 3b4434ec5d9e5..f3b69561e9af7 100644 --- a/x-pack/libs/es-opensaml-security-api/build.gradle +++ b/x-pack/libs/es-opensaml-security-api/build.gradle @@ -5,6 +5,8 @@ * 2.0. */ +import org.elasticsearch.gradle.internal.AbstractDependenciesTask + apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.publish' apply plugin: 'com.gradleup.shadow' @@ -20,7 +22,7 @@ dependencies { } } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /opensaml-.*/, to: 'shibboleth' } diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index 315065fba3524..fa4a5c7d36919 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -3,6 +3,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.Version import java.nio.file.Paths +import org.elasticsearch.gradle.internal.AbstractDependenciesTask apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.publish' @@ -24,7 +25,7 @@ esplugin { requiresKeystore =false } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /http.*/, to: 'httpclient' // pulled in by rest client mapping from: /commons-.*/, to: 'commons' // pulled in by rest client } diff --git a/x-pack/plugin/identity-provider/build.gradle b/x-pack/plugin/identity-provider/build.gradle index 32d977ac95d97..3bec9b947b379 100644 --- a/x-pack/plugin/identity-provider/build.gradle +++ b/x-pack/plugin/identity-provider/build.gradle @@ -1,4 +1,13 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import org.elasticsearch.gradle.internal.AbstractDependenciesTask import org.elasticsearch.gradle.internal.info.BuildParams + apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { @@ -60,7 +69,7 @@ dependencies { } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /java-support|opensaml-.*/, to: 'shibboleth' mapping from: /http.*/, to: 'httpclient' mapping from: /bc.*/, to: 'bouncycastle' diff --git a/x-pack/plugin/inference/build.gradle b/x-pack/plugin/inference/build.gradle index ebedaf52b253c..ead962b6608cd 100644 --- a/x-pack/plugin/inference/build.gradle +++ b/x-pack/plugin/inference/build.gradle @@ -6,6 +6,8 @@ */ import org.elasticsearch.gradle.internal.info.BuildParams +import org.elasticsearch.gradle.internal.AbstractDependenciesTask + apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.internal-yaml-rest-test' @@ -109,7 +111,7 @@ dependencies { runtimeOnly "org.slf4j:slf4j-nop:${versions.slf4j}" } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /google-auth-.*/, to: 'google-auth' mapping from: /google-http-.*/, to: 'google-http' mapping from: /opencensus.*/, to: 'opencensus' diff --git a/x-pack/plugin/security/build.gradle b/x-pack/plugin/security/build.gradle index deaeb03ffecc1..47631ed2f4e10 100644 --- a/x-pack/plugin/security/build.gradle +++ b/x-pack/plugin/security/build.gradle @@ -1,3 +1,5 @@ +import org.elasticsearch.gradle.internal.AbstractDependenciesTask + apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.publish' apply plugin: 'elasticsearch.internal-cluster-test' @@ -172,7 +174,7 @@ tasks.named('assemble').configure { dependsOn tasks.named('jar') } -tasks.named("dependencyLicenses").configure { +tasks.withType(AbstractDependenciesTask).configureEach { mapping from: /java-support|opensaml-.*/, to: 'shibboleth' mapping from: /http.*/, to: 'httpclient' mapping from: /bc.*/, to: 'bouncycastle'