diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 8ef52c7af34..c3c2c8bb675 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -18,16 +18,11 @@ */ package org.elasticsearch.gradle -import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin -import com.github.jengelman.gradle.plugins.shadow.ShadowExtension -import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + import groovy.transform.CompileStatic -import nebula.plugin.info.InfoBrokerPlugin import org.apache.commons.io.IOUtils import org.elasticsearch.gradle.info.BuildParams import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin -import org.elasticsearch.gradle.plugin.PluginBuildPlugin import org.elasticsearch.gradle.precommit.DependencyLicensesTask import org.elasticsearch.gradle.precommit.PrecommitTasks import org.elasticsearch.gradle.test.ErrorReportingTestListener @@ -43,7 +38,6 @@ import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task -import org.gradle.api.XmlProvider import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.Dependency import org.gradle.api.artifacts.ModuleDependency @@ -55,32 +49,15 @@ import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout import org.gradle.api.artifacts.repositories.MavenArtifactRepository import org.gradle.api.credentials.HttpHeaderCredentials import org.gradle.api.execution.TaskActionListener -import org.gradle.api.file.CopySpec -import org.gradle.api.plugins.BasePlugin -import org.gradle.api.plugins.BasePluginConvention import org.gradle.api.plugins.ExtraPropertiesExtension import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.publish.maven.plugins.MavenPublishPlugin -import org.gradle.api.publish.maven.tasks.GenerateMavenPom -import org.gradle.api.tasks.SourceSet -import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Jar -import org.gradle.api.tasks.compile.JavaCompile -import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.api.tasks.testing.Test import org.gradle.authentication.http.HttpHeaderAuthentication -import org.gradle.external.javadoc.CoreJavadocOptions -import org.gradle.internal.jvm.Jvm import org.gradle.language.base.plugins.LifecycleBasePlugin import org.gradle.util.GradleVersion import java.nio.charset.StandardCharsets -import java.nio.file.Files - -import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure /** * Encapsulates build configuration for elasticsearch projects. @@ -112,6 +89,7 @@ class BuildPlugin implements Plugin { } project.pluginManager.apply('elasticsearch.java') project.pluginManager.apply('elasticsearch.publish') + project.pluginManager.apply(DependenciesInfoPlugin) // apply global test task failure listener project.rootProject.pluginManager.apply(TestFailureReportingPlugin) @@ -121,7 +99,6 @@ class BuildPlugin implements Plugin { configureRepositories(project) project.extensions.getByType(ExtraPropertiesExtension).set('versions', VersionProperties.versions) configurePrecommit(project) - configureDependenciesInfo(project) configureFips140(project) } @@ -311,16 +288,6 @@ class BuildPlugin implements Plugin { } } - private static configureDependenciesInfo(Project project) { - project.tasks.register("dependenciesInfo", DependenciesInfoTask, { DependenciesInfoTask task -> - task.runtimeConfiguration = project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) - task.compileOnlyConfiguration = project.configurations.getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) - task.getConventionMapping().map('mappings') { - (project.tasks.getByName('dependencyLicenses') as DependencyLicensesTask).mappings - } - } as Action) - } - private static class TestFailureReportingPlugin implements Plugin { @Override void apply(Project project) { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/DependenciesInfoPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/DependenciesInfoPlugin.groovy new file mode 100644 index 00000000000..d7496b76e2a --- /dev/null +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/DependenciesInfoPlugin.groovy @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.gradle + +import org.elasticsearch.gradle.precommit.DependencyLicensesTask +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.tasks.TaskProvider + +class DependenciesInfoPlugin implements Plugin { + @Override + public void apply(Project project) { + TaskProvider depsInfo = project.getTasks().register("dependenciesInfo", DependenciesInfoTask.class); + depsInfo.configure { DependenciesInfoTask t -> + t.setRuntimeConfiguration(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)); + t.setCompileOnlyConfiguration(project.getConfigurations().getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME)); + t.getConventionMapping().map("mappings") { -> + TaskProvider depLic = project.getTasks().named("dependencyLicenses", DependencyLicensesTask.class); + return depLic.get().getMappings(); + } + }; + } +}