forked from bazelbuild/rules_java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_utils.bzl
More file actions
25 lines (21 loc) · 699 Bytes
/
java_utils.bzl
File metadata and controls
25 lines (21 loc) · 699 Bytes
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
"""Utility methods for interacting with the java rules"""
def _tokenize_javacopts(ctx, opts):
"""Tokenizes a list or depset of options to a list.
Iff opts is a depset, we reverse the flattened list to ensure right-most
duplicates are preserved in their correct position.
Args:
ctx: (RuleContext) the rule context
opts: (depset[str]|[str]) the javac options to tokenize
Returns:
[str] list of tokenized options
"""
if hasattr(opts, "to_list"):
opts = reversed(opts.to_list())
return [
token
for opt in opts
for token in ctx.tokenize(opt)
]
utils = struct(
tokenize_javacopts = _tokenize_javacopts,
)