|
14 | 14 |
|
15 | 15 | """ Private utilities for Java compilation support in Starlark. """ |
16 | 16 |
|
| 17 | +load( |
| 18 | + "@bazel_features//private:util.bzl", |
| 19 | + "BAZEL_VERSION", |
| 20 | + _bazel_version_ge = "ge", |
| 21 | +) |
17 | 22 | load("@bazel_skylib//lib:paths.bzl", "paths") |
18 | 23 | load("//java/common:java_semantics.bzl", "semantics") |
19 | 24 | load("//java/common/rules:java_helper.bzl", "helper") |
|
27 | 32 | ) |
28 | 33 | load(":native.bzl", "get_internal_java_common") |
29 | 34 |
|
| 35 | +_HAS_UNUSED_DEPS_MODE = BAZEL_VERSION[0] == [999999, 999999, 999999] or _bazel_version_ge("9.2.0") |
| 36 | + |
30 | 37 | # copybara: default multiline visibility |
31 | 38 |
|
32 | 39 | _STRICT_DEPS_VALUES = [ |
@@ -195,6 +202,7 @@ def compile( |
195 | 202 | compilation action will output in addition to the class jar from annotation processing. |
196 | 203 | strict_deps: (str) A string that specifies how to handle strict deps. Possible values: |
197 | 204 | 'OFF', 'ERROR', 'WARN' and 'DEFAULT'. |
| 205 | + unused_deps_mode: (str) Unused dependency checking mode. |
198 | 206 | bootclasspath: (BootClassPathInfo) If present, overrides the bootclasspath associated with |
199 | 207 | the provided java_toolchain. Optional. |
200 | 208 | javabuilder_jvm_flags: (list[str]) Additional JVM flags to pass to JavaBuilder. |
@@ -315,6 +323,10 @@ def compile( |
315 | 323 | if uses_annotation_processing: |
316 | 324 | generated_class_jar = _derive_output_file(ctx, output, name_suffix = "-gen") |
317 | 325 | generated_source_jar = _derive_output_file(ctx, output, name_suffix = "-gensrc") |
| 326 | + compilation_action_kwargs = {} |
| 327 | + if _HAS_UNUSED_DEPS_MODE: |
| 328 | + compilation_action_kwargs["unused_deps_mode"] = unused_deps_mode |
| 329 | + |
318 | 330 | get_internal_java_common().create_compilation_action( |
319 | 331 | ctx, |
320 | 332 | java_toolchain, |
@@ -344,7 +356,7 @@ def compile( |
344 | 356 | enable_direct_classpath, |
345 | 357 | annotation_processor_additional_inputs, |
346 | 358 | annotation_processor_additional_outputs, |
347 | | - unused_deps_mode = unused_deps_mode, |
| 359 | + **compilation_action_kwargs |
348 | 360 | ) |
349 | 361 |
|
350 | 362 | create_output_source_jar = len(source_files) > 0 or source_jars != [output_source_jar] |
|
0 commit comments