-
Notifications
You must be signed in to change notification settings - Fork 0
/
multirelease.bzl
53 lines (47 loc) · 1.9 KB
/
multirelease.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def _java8_transition_implementation(setting, attr):
return {
"//command_line_option:javabase": "@local_jdk8//:jdk", # There is no @remote_jdk8 repository.
"//command_line_option:java_toolchain": "@bazel_tools//tools/jdk:toolchain_java8",
}
java8_transition = transition(
implementation = _java8_transition_implementation,
inputs = [],
outputs = ["//command_line_option:javabase", "//command_line_option:java_toolchain"],
)
def _java11_transition_implementation(setting, attr):
return {
"//command_line_option:javabase": "@remotejdk11_linux//:jdk",
"//command_line_option:java_toolchain": "@bazel_tools//tools/jdk:toolchain_java11",
}
java11_transition = transition(
implementation = _java11_transition_implementation,
inputs = [],
outputs = ["//command_line_option:javabase", "//command_line_option:java_toolchain"],
)
def _java_multirelease_binary_impl(ctx):
inputs = ctx.files.deps8 + ctx.files.deps11
jar = ctx.actions.declare_file(ctx.attr.name + ".jar")
args = ctx.actions.args()
args.add_all("--sources", inputs)
args.add("--output", jar)
ctx.actions.run(
inputs = inputs,
outputs = [jar],
executable = ctx.attr._java_toolchain[java_common.JavaToolchainInfo].single_jar,
arguments = [args],
)
return [DefaultInfo(files = depset([jar]))]
java_multirelease_binary = rule(
implementation = _java_multirelease_binary_impl,
attrs = {
"deps8": attr.label_list(cfg = java8_transition),
"deps11": attr.label_list(cfg = java11_transition),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
"_java_toolchain": attr.label(
default = "@bazel_tools//tools/jdk:current_java_toolchain",
providers = [java_common.JavaRuntimeInfo],
),
},
)