-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathgroovy_rules.bzl
195 lines (174 loc) · 9.48 KB
/
groovy_rules.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under both the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree and the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.
# TODO(cjhopman): This was generated by scripts/hacks/rules_shim_with_docs.py,
# but should be manually edited going forward. There may be some errors in
# the generated docs, and so those should be verified to be accurate and
# well-formatted (and then delete this TODO)
load(":common.bzl", "ForkMode", "LogLevel", "SourceAbiVerificationMode", "TestType", "UnusedDependenciesAction", "prelude_rule")
load(":jvm_common.bzl", "jvm_common")
groovy_library = prelude_rule(
name = "groovy_library",
docs = """
A `groovy_library()` rule is used to define a set of Groovy files that can be compiled
together. It can also be used to cross compile a set of Groovy and Java files. The main output of a
`groovy_library()` rule is a single JAR file containing all of the compiled class
files and resources.
""",
examples = """
```
# A rule that compiles a single .groovy file.
groovy_library(
name = 'example',
srcs = ['MySourceFile.groovy'],
)
```
```
# A rule that compiles all of the .groovy files under the directory in
# which the rule is defined using glob()
groovy_library(
name = 'groovy-only',
srcs = glob(['**/*.groovy']),
)
```
```
# A rule that cross compiles all of the .groovy and .java files under
# the directory in which the rule is defined, failing if compiling the
# java files generates any compiler warnings
groovy_library(
name = 'cross-compilation',
srcs = glob(['**/*.groovy', '**/*.java']),
java_version = 8,
extra_arguments = [
'-Werror',
],
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
{
"srcs": attrs.list(attrs.source(), default = [], doc = """
The set of files to compile for this rule.
Usually these will all end in `.groovy`, but if any of the files end in
`.java`, cross compilation using the jdk found in `JAVA_HOME` will occur.
"""),
"resources": attrs.list(attrs.source(), default = [], doc = """
This is the same as in `java_library()`.
"""),
"deps": attrs.list(attrs.dep(), default = [], doc = """
Rules (usually other `groovy_library` or ``java_library()`` rules)
that are used to generate the classpath required to compile this `groovy_library`.
This is the same as in `java_library()`.
"""),
"exported_deps": attrs.list(attrs.dep(), default = [], doc = """
Other `groovy_library` and ``java_library()`` rules that depend
on this rule will also include its `exported_deps` in their classpaths.
This is the same as in `java_library()`.
"""),
"provided_deps": attrs.list(attrs.dep(), default = [], doc = """
This is the same as in `java_library()`.
"""),
"extra_groovyc_arguments": attrs.list(attrs.string(), default = [], doc = """
List of additional arguments to pass into the Groovy compiler.
"""),
"source": attrs.option(attrs.string(), default = None, doc = """
Only used during cross compilation.
This is the same as in `java_library()`.
"""),
"target": attrs.option(attrs.string(), default = None, doc = """
Only used during cross compilation.
This is the same as in `java_library()`.
"""),
"java_version": attrs.option(attrs.string(), default = None, doc = """
Only used during cross compilation.
This is the same as in `java_library()`.
"""),
"extra_arguments": attrs.list(attrs.string(), default = [], doc = """
Only used during cross compilation.
This is the same as in `java_library()`.
"""),
"annotation_processor_deps": attrs.list(attrs.dep(), default = []),
"annotation_processor_params": attrs.list(attrs.string(), default = []),
"annotation_processors": attrs.list(attrs.string(), default = []),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"exported_provided_deps": attrs.list(attrs.dep(), default = []),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"manifest_file": attrs.option(attrs.source(), default = None),
"maven_coords": attrs.option(attrs.string(), default = None),
"never_mark_as_unused_dependency": attrs.option(attrs.bool(), default = None),
"on_unused_dependencies": attrs.option(attrs.enum(UnusedDependenciesAction), default = None),
"proguard_config": attrs.option(attrs.source(), default = None),
"remove_classes": attrs.list(attrs.regex(), default = []),
"required_for_source_only_abi": attrs.bool(default = False),
"resources_root": attrs.option(attrs.source(), default = None),
"runtime_deps": attrs.list(attrs.dep(), default = []),
"source_abi_verification_mode": attrs.option(attrs.enum(SourceAbiVerificationMode), default = None),
"source_only_abi_deps": attrs.list(attrs.dep(), default = []),
}
) | jvm_common.plugins() | jvm_common.javac(),
)
groovy_test = prelude_rule(
name = "groovy_test",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
"annotation_processor_deps": attrs.list(attrs.dep(), default = []),
"annotation_processor_params": attrs.list(attrs.string(), default = []),
"annotation_processors": attrs.list(attrs.string(), default = []),
"contacts": attrs.list(attrs.string(), default = []),
"cxx_library_whitelist": attrs.list(attrs.dep(), default = []),
"default_cxx_platform": attrs.option(attrs.string(), default = None),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"deps": attrs.list(attrs.dep(), default = []),
"deps_query": attrs.option(attrs.query(), default = None),
"env": attrs.dict(key = attrs.string(), value = attrs.arg(), sorted = False, default = {}),
"exported_deps": attrs.list(attrs.dep(), default = []),
"exported_provided_deps": attrs.list(attrs.dep(), default = []),
"extra_arguments": attrs.list(attrs.string(), default = []),
"extra_groovyc_arguments": attrs.list(attrs.string(), default = []),
"fork_mode": attrs.enum(ForkMode, default = "none"),
"java_version": attrs.option(attrs.string(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"manifest_file": attrs.option(attrs.source(), default = None),
"maven_coords": attrs.option(attrs.string(), default = None),
"never_mark_as_unused_dependency": attrs.option(attrs.bool(), default = None),
"on_unused_dependencies": attrs.option(attrs.enum(UnusedDependenciesAction), default = None),
"proguard_config": attrs.option(attrs.source(), default = None),
"provided_deps": attrs.list(attrs.dep(), default = []),
"remove_classes": attrs.list(attrs.regex(), default = []),
"required_for_source_only_abi": attrs.bool(default = False),
"resources": attrs.list(attrs.source(), default = []),
"resources_root": attrs.option(attrs.source(), default = None),
"run_test_separately": attrs.bool(default = False),
"runtime_deps": attrs.list(attrs.dep(), default = []),
"source": attrs.option(attrs.string(), default = None),
"source_abi_verification_mode": attrs.option(attrs.enum(SourceAbiVerificationMode), default = None),
"source_only_abi_deps": attrs.list(attrs.dep(), default = []),
"srcs": attrs.list(attrs.source(), default = []),
"std_err_log_level": attrs.option(attrs.one_of(attrs.enum(LogLevel), attrs.int()), default = None),
"std_out_log_level": attrs.option(attrs.one_of(attrs.enum(LogLevel), attrs.int()), default = None),
"target": attrs.option(attrs.string(), default = None),
"test_case_timeout_ms": attrs.option(attrs.int(), default = None),
"test_rule_timeout_ms": attrs.option(attrs.int(), default = None),
"test_type": attrs.option(attrs.enum(TestType), default = None),
"use_cxx_libraries": attrs.option(attrs.bool(), default = None),
"use_dependency_order_classpath": attrs.option(attrs.bool(), default = None),
"vm_args": attrs.list(attrs.arg(), default = []),
}
) | jvm_common.plugins() | jvm_common.javac(),
)
groovy_rules = struct(
groovy_library = groovy_library,
groovy_test = groovy_test,
)