diff --git a/aspect/BUILD b/aspect/BUILD index 4e75c617042..dee23322e93 100644 --- a/aspect/BUILD +++ b/aspect/BUILD @@ -32,6 +32,7 @@ filegroup( "WORKSPACE", "artifacts.bzl", "build_dependencies.bzl", + "build_render_dependencies.bzl", "fast_build_info_bundled.bzl", "intellij_info.bzl", "intellij_info_bundled.bzl", diff --git a/aspect/build_render_dependencies.bzl b/aspect/build_render_dependencies.bzl new file mode 100644 index 00000000000..fb66007ca60 --- /dev/null +++ b/aspect/build_render_dependencies.bzl @@ -0,0 +1,36 @@ +"""Aspects to build and collect project's render dependencies.""" + +load("@rules_java//java:defs.bzl", "JavaInfo") + +RenderDependenciesInfo = provider( + "The render dependencies", + fields = { + "jars": "a list of jars generated for project files and external dependencies", + }, +) + +def _package_render_dependencies_impl(target, ctx): + return [OutputGroupInfo( + jars = target[RenderDependenciesInfo].jars.to_list(), + )] + +package_render_dependencies = aspect( + implementation = _package_render_dependencies_impl, + required_aspect_providers = [[RenderDependenciesInfo]], +) + +def _collect_render_dependencies_impl(target, ctx): + if JavaInfo not in target: + return [RenderDependenciesInfo( + jars = depset(), + )] + return [ + RenderDependenciesInfo( + jars = depset([], transitive = [target[JavaInfo].transitive_runtime_jars]), + ), + ] + +collect_render_dependencies = aspect( + implementation = _collect_render_dependencies_impl, + provides = [RenderDependenciesInfo], +)