Skip to content

Commit 3b69871

Browse files
erikkerbervaleraz
andauthored
Add x_annotation_default_target kotlinc option (#1314)
Co-authored-by: Valera Zakharov <[email protected]>
1 parent 28d6379 commit 3b69871

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

docs/kotlin.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ Define java compiler options for `kt_jvm_*` rules with java sources.
380380
<pre>
381381
load("@rules_kotlin//kotlin:core.bzl", "kt_kotlinc_options")
382382

383-
kt_kotlinc_options(<a href="#kt_kotlinc_options-name">name</a>, <a href="#kt_kotlinc_options-include_stdlibs">include_stdlibs</a>, <a href="#kt_kotlinc_options-java_parameters">java_parameters</a>, <a href="#kt_kotlinc_options-jvm_target">jvm_target</a>, <a href="#kt_kotlinc_options-warn">warn</a>, <a href="#kt_kotlinc_options-x_assertions">x_assertions</a>,
384-
<a href="#kt_kotlinc_options-x_backend_threads">x_backend_threads</a>, <a href="#kt_kotlinc_options-x_consistent_data_class_copy_visibility">x_consistent_data_class_copy_visibility</a>, <a href="#kt_kotlinc_options-x_context_receivers">x_context_receivers</a>,
383+
kt_kotlinc_options(<a href="#kt_kotlinc_options-name">name</a>, <a href="#kt_kotlinc_options-include_stdlibs">include_stdlibs</a>, <a href="#kt_kotlinc_options-java_parameters">java_parameters</a>, <a href="#kt_kotlinc_options-jvm_target">jvm_target</a>, <a href="#kt_kotlinc_options-warn">warn</a>,
384+
<a href="#kt_kotlinc_options-x_annotation_default_target">x_annotation_default_target</a>, <a href="#kt_kotlinc_options-x_assertions">x_assertions</a>, <a href="#kt_kotlinc_options-x_backend_threads">x_backend_threads</a>,
385+
<a href="#kt_kotlinc_options-x_consistent_data_class_copy_visibility">x_consistent_data_class_copy_visibility</a>, <a href="#kt_kotlinc_options-x_context_receivers">x_context_receivers</a>,
385386
<a href="#kt_kotlinc_options-x_emit_jvm_type_annotations">x_emit_jvm_type_annotations</a>, <a href="#kt_kotlinc_options-x_enable_incremental_compilation">x_enable_incremental_compilation</a>, <a href="#kt_kotlinc_options-x_explicit_api_mode">x_explicit_api_mode</a>,
386387
<a href="#kt_kotlinc_options-x_inline_classes">x_inline_classes</a>, <a href="#kt_kotlinc_options-x_jdk_release">x_jdk_release</a>, <a href="#kt_kotlinc_options-x_jspecify_annotations">x_jspecify_annotations</a>, <a href="#kt_kotlinc_options-x_jsr_305">x_jsr_305</a>, <a href="#kt_kotlinc_options-x_jvm_default">x_jvm_default</a>,
387388
<a href="#kt_kotlinc_options-x_lambdas">x_lambdas</a>, <a href="#kt_kotlinc_options-x_multi_platform">x_multi_platform</a>, <a href="#kt_kotlinc_options-x_no_call_assertions">x_no_call_assertions</a>, <a href="#kt_kotlinc_options-x_no_optimize">x_no_optimize</a>,
@@ -403,6 +404,7 @@ Define kotlin compiler options.
403404
| <a id="kt_kotlinc_options-java_parameters"></a>java_parameters | Generate metadata for Java 1.8+ reflection on method parameters. | Boolean | optional | `False` |
404405
| <a id="kt_kotlinc_options-jvm_target"></a>jvm_target | The target version of the generated JVM bytecode | String | optional | `""` |
405406
| <a id="kt_kotlinc_options-warn"></a>warn | Control warning behaviour. | String | optional | `"report"` |
407+
| <a id="kt_kotlinc_options-x_annotation_default_target"></a>x_annotation_default_target | Change the default annotation targets for constructor properties: -Xannotation-default-target=first-only: use the first of the following allowed targets: '@param:', '@property:', '@field:'; -Xannotation-default-target=first-only-warn: same as first-only, and raise warnings when both '@param:' and either '@property:' or '@field:' are allowed; -Xannotation-default-target=param-property: use '@param:' target if applicable, and also use the first of either '@property:' or '@field:'; default: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1 and before. | String | optional | `"off"` |
406408
| <a id="kt_kotlinc_options-x_assertions"></a>x_assertions | Configures how assertions are handled. The 'jvm' option enables assertions in JVM code. | String | optional | `""` |
407409
| <a id="kt_kotlinc_options-x_backend_threads"></a>x_backend_threads | When using the IR backend, run lowerings by file in N parallel threads. 0 means use a thread per processor core. Default value is 1. | Integer | optional | `1` |
408410
| <a id="kt_kotlinc_options-x_consistent_data_class_copy_visibility"></a>x_consistent_data_class_copy_visibility | The effect of this compiler flag is the same as applying @ConsistentCopyVisibility annotation to all data classes in the module. See https://youtrack.jetbrains.com/issue/KT-11914 | Boolean | optional | `False` |

src/main/starlark/core/options/opts.kotlinc.bzl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@ _KOPTS_ALL = {
191191
"strict": ["-Xexplicit-api=strict"],
192192
},
193193
),
194+
"x_annotation_default_target": struct(
195+
args = dict(
196+
default = "off",
197+
doc = """Change the default annotation targets for constructor properties:
198+
-Xannotation-default-target=first-only: use the first of the following allowed targets: '@param:', '@property:', '@field:';
199+
-Xannotation-default-target=first-only-warn: same as first-only, and raise warnings when both '@param:' and either '@property:' or '@field:' are allowed;
200+
-Xannotation-default-target=param-property: use '@param:' target if applicable, and also use the first of either '@property:' or '@field:';
201+
default: 'first-only-warn' in language version 2.2+, 'first-only' in version 2.1 and before.""",
202+
values = ["off", "first-only", "first-only-warn", "param-property"],
203+
),
204+
type = attr.string,
205+
value_to_flag = {
206+
"off": None,
207+
"first-only": ["-Xannotation-default-target=first-only"],
208+
"first-only-warn": ["-Xannotation-default-target=first-only-warn"],
209+
"param-property": ["-Xannotation-default-target=param-property"],
210+
},
211+
),
194212
"java_parameters": struct(
195213
args = dict(
196214
default = False,

0 commit comments

Comments
 (0)