Split dependenciesInfo task to its own plugin (#56957)
The dependenciesInfo task is used to gather information about all dependencies in elasticsearch. This commit separates it into its own gradle plugin.
This commit is contained in:
parent
b7c6f0d02f
commit
acfa2e4241
|
@ -18,16 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.gradle
|
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 groovy.transform.CompileStatic
|
||||||
import nebula.plugin.info.InfoBrokerPlugin
|
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.elasticsearch.gradle.info.BuildParams
|
import org.elasticsearch.gradle.info.BuildParams
|
||||||
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
|
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
|
||||||
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
|
||||||
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
|
||||||
import org.elasticsearch.gradle.precommit.PrecommitTasks
|
import org.elasticsearch.gradle.precommit.PrecommitTasks
|
||||||
import org.elasticsearch.gradle.test.ErrorReportingTestListener
|
import org.elasticsearch.gradle.test.ErrorReportingTestListener
|
||||||
|
@ -43,7 +38,6 @@ import org.gradle.api.NamedDomainObjectContainer
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.XmlProvider
|
|
||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.artifacts.Dependency
|
import org.gradle.api.artifacts.Dependency
|
||||||
import org.gradle.api.artifacts.ModuleDependency
|
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.artifacts.repositories.MavenArtifactRepository
|
||||||
import org.gradle.api.credentials.HttpHeaderCredentials
|
import org.gradle.api.credentials.HttpHeaderCredentials
|
||||||
import org.gradle.api.execution.TaskActionListener
|
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.ExtraPropertiesExtension
|
||||||
import org.gradle.api.plugins.JavaPlugin
|
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.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.api.tasks.testing.Test
|
||||||
import org.gradle.authentication.http.HttpHeaderAuthentication
|
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.language.base.plugins.LifecycleBasePlugin
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates build configuration for elasticsearch projects.
|
* Encapsulates build configuration for elasticsearch projects.
|
||||||
|
@ -112,6 +89,7 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
}
|
}
|
||||||
project.pluginManager.apply('elasticsearch.java')
|
project.pluginManager.apply('elasticsearch.java')
|
||||||
project.pluginManager.apply('elasticsearch.publish')
|
project.pluginManager.apply('elasticsearch.publish')
|
||||||
|
project.pluginManager.apply(DependenciesInfoPlugin)
|
||||||
|
|
||||||
// apply global test task failure listener
|
// apply global test task failure listener
|
||||||
project.rootProject.pluginManager.apply(TestFailureReportingPlugin)
|
project.rootProject.pluginManager.apply(TestFailureReportingPlugin)
|
||||||
|
@ -121,7 +99,6 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
configureRepositories(project)
|
configureRepositories(project)
|
||||||
project.extensions.getByType(ExtraPropertiesExtension).set('versions', VersionProperties.versions)
|
project.extensions.getByType(ExtraPropertiesExtension).set('versions', VersionProperties.versions)
|
||||||
configurePrecommit(project)
|
configurePrecommit(project)
|
||||||
configureDependenciesInfo(project)
|
|
||||||
configureFips140(project)
|
configureFips140(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,16 +288,6 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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<DependenciesInfoTask>)
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TestFailureReportingPlugin implements Plugin<Project> {
|
private static class TestFailureReportingPlugin implements Plugin<Project> {
|
||||||
@Override
|
@Override
|
||||||
void apply(Project project) {
|
void apply(Project project) {
|
||||||
|
|
|
@ -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<Project> {
|
||||||
|
@Override
|
||||||
|
public void apply(Project project) {
|
||||||
|
TaskProvider<DependenciesInfoTask> 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<DependencyLicensesTask> depLic = project.getTasks().named("dependencyLicenses", DependencyLicensesTask.class);
|
||||||
|
return depLic.get().getMappings();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue