DependenciesInfoPlugin.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
  3. * or more contributor license agreements. Licensed under the Elastic License
  4. * 2.0 and the Server Side Public License, v 1; you may not use this file except
  5. * in compliance with, at your election, the Elastic License 2.0 or the Server
  6. * Side Public License, v 1.
  7. */
  8. package org.elasticsearch.gradle.internal;
  9. import org.elasticsearch.gradle.dependencies.CompileOnlyResolvePlugin;
  10. import org.elasticsearch.gradle.internal.precommit.DependencyLicensesTask;
  11. import org.gradle.api.Plugin;
  12. import org.gradle.api.Project;
  13. import org.gradle.api.plugins.JavaPlugin;
  14. public class DependenciesInfoPlugin implements Plugin<Project> {
  15. @Override
  16. public void apply(final Project project) {
  17. project.getPlugins().apply(CompileOnlyResolvePlugin.class);
  18. var depsInfo = project.getTasks().register("dependenciesInfo", DependenciesInfoTask.class);
  19. depsInfo.configure(t -> {
  20. t.setRuntimeConfiguration(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
  21. t.setCompileOnlyConfiguration(
  22. project.getConfigurations().getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME)
  23. );
  24. t.getConventionMapping().map("mappings", () -> {
  25. var depLic = project.getTasks().named("dependencyLicenses", DependencyLicensesTask.class);
  26. return depLic.get().getMappings();
  27. });
  28. });
  29. }
  30. }