Skip to content

Commit

Permalink
Expose JavaRuntimeClasspathInfo
Browse files Browse the repository at this point in the history
And make that a requirement for deploy_env.

This is a first step in providing a separate rule for non-executable java_binary.

PiperOrigin-RevId: 560151620
Change-Id: I9cb2d3c18ad225318f016a50f2cb950d763224ed
  • Loading branch information
comius authored and pull[bot] committed Dec 15, 2023
1 parent 2db83b4 commit 3092086
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/main/starlark/builtins_bzl/common/java/java_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ InternalDeployJarInfo = provider(
],
)

JavaRuntimeClasspathInfo = provider(
"Provider for the runtime classpath contributions of a Java binary.",
fields = ["runtime_classpath"],
)

def basic_java_binary(
ctx,
deps,
Expand Down Expand Up @@ -281,7 +276,7 @@ def basic_java_binary(
"OutputGroupInfo": OutputGroupInfo(**output_groups),
"JavaInfo": java_binary_info,
"InstrumentedFilesInfo": target["InstrumentedFilesInfo"],
"JavaRuntimeClasspathInfo": JavaRuntimeClasspathInfo(runtime_classpath = java_info.transitive_runtime_jars),
"JavaRuntimeClasspathInfo": java_common.JavaRuntimeClasspathInfo(runtime_classpath = java_info.transitive_runtime_jars),
"InternalDeployJarInfo": InternalDeployJarInfo(
java_attrs = java_attrs,
launcher_info = struct(
Expand All @@ -303,7 +298,7 @@ def basic_java_binary(

def _collect_attrs(ctx, runtime_classpath, classpath_resources):
deploy_env_jars = depset(transitive = [
dep[JavaRuntimeClasspathInfo].runtime_classpath
dep[java_common.JavaRuntimeClasspathInfo].runtime_classpath
for dep in ctx.attr.deploy_env
]) if hasattr(ctx.attr, "deploy_env") else depset()

Expand Down Expand Up @@ -515,7 +510,7 @@ BASIC_JAVA_BINARY_ATTRIBUTES = merge_attrs(
cfg = "exec",
),
"deploy_env": attr.label_list(
allow_rules = ["java_binary"],
providers = [java_common.JavaRuntimeClasspathInfo],
allow_files = False,
),
"launcher": attr.label(
Expand Down
5 changes: 5 additions & 0 deletions src/main/starlark/builtins_bzl/common/java/java_common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ load(":common/java/java_helper.bzl", "helper")

_java_common_internal = _builtins.internal.java_common_internal_do_not_use
JavaToolchainInfo = _java_common_internal.JavaToolchainInfo
JavaRuntimeClasspathInfo = provider(
"Provider for the runtime classpath contributions of a Java binary.",
fields = ["runtime_classpath"],
)

def _compile(
ctx,
Expand Down Expand Up @@ -298,6 +302,7 @@ def _make_java_common():
"JavaToolchainInfo": JavaToolchainInfo,
"JavaRuntimeInfo": _java_common_internal.JavaRuntimeInfo,
"BootClassPathInfo": _java_common_internal.BootClassPathInfo,
"JavaRuntimeClasspathInfo": JavaRuntimeClasspathInfo,
"experimental_java_proto_library_default_has_services": _java_common_internal.experimental_java_proto_library_default_has_services,
}
if _java_common_internal._google_legacy_api_enabled():
Expand Down

0 comments on commit 3092086

Please sign in to comment.