forked from bazelbuild/rules_java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_binary_wrapper.bzl
More file actions
73 lines (61 loc) · 2.68 KB
/
java_binary_wrapper.bzl
File metadata and controls
73 lines (61 loc) · 2.68 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed 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.
"""Macro encapsulating the java_binary implementation
This is needed since the `executable` nature of the target must be computed from
the supplied value of the `create_executable` attribute.
"""
load("//java/common:java_semantics.bzl", "semantics")
# copybara: default visibility
def register_legacy_java_binary_rules(
rule_exec,
rule_nonexec,
**kwargs):
"""Registers the correct java_binary rule and deploy jar rule
Args:
rule_exec: (Rule) The executable java_binary rule
rule_nonexec: (Rule) The non-executable java_binary rule
**kwargs: Actual args to instantiate the rule
"""
create_executable = "create_executable" not in kwargs or kwargs["create_executable"]
# TODO(hvd): migrate depot to integers / maybe use decompose_select_list()
if "stamp" in kwargs and type(kwargs["stamp"]) == type(True):
kwargs["stamp"] = 1 if kwargs["stamp"] else 0
if not create_executable:
rule_nonexec(**kwargs)
else:
if "use_launcher" in kwargs and not kwargs["use_launcher"]:
kwargs["launcher"] = None
else:
# If launcher is not set or None, set it to config flag
if "launcher" not in kwargs or not kwargs["launcher"]:
kwargs["launcher"] = semantics.LAUNCHER_FLAG_LABEL
rule_exec(**kwargs)
def register_java_binary_rules(
java_binary,
**kwargs):
"""Creates a java_binary rule and a deploy jar rule
Args:
java_binary: (Rule) The executable java_binary rule
**kwargs: Actual args to instantiate the rule
"""
# TODO(hvd): migrate depot to integers / maybe use decompose_select_list()
if "stamp" in kwargs and type(kwargs["stamp"]) == type(True):
kwargs["stamp"] = 1 if kwargs["stamp"] else 0
if "use_launcher" in kwargs and not kwargs["use_launcher"]:
kwargs["launcher"] = None
else:
# If launcher is not set or None, set it to config flag
if "launcher" not in kwargs or not kwargs["launcher"]:
kwargs["launcher"] = semantics.LAUNCHER_FLAG_LABEL
java_binary(**kwargs)