diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index dd0751ba6..6a5430f96 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -56,6 +56,8 @@ tasks: stardoc: name: Stardoc api documentation platform: ubuntu1804 + build_flags: + - "--enable_bzlmod=true" build_targets: - //kotlin:stardoc test_targets: diff --git a/BUILD b/BUILD index bd8e153d3..f0c90a3a7 100644 --- a/BUILD +++ b/BUILD @@ -36,7 +36,6 @@ ktlint_config( test_suite( name = "all_tests", tests = [ - "//docs:are_docs_up_to_date_test", "//src/test/kotlin/io/bazel/kotlin:assertion_tests", "//src/test/kotlin/io/bazel/kotlin/builder:builder_tests", "//src/test/kotlin/io/bazel/kotlin/integration:integration_tests", diff --git a/MODULE.bazel b/MODULE.bazel index dc141c4a9..273d8bd9b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -90,7 +90,7 @@ maven.install( use_repo(maven, "kotlin_rules_maven", "unpinned_kotlin_rules_maven") bazel_dep(name = "rules_pkg", version = "0.7.0") -bazel_dep(name = "stardoc", version = "0.5.6", repo_name = "io_bazel_stardoc") +bazel_dep(name = "stardoc", version = "0.7.0", repo_name = "io_bazel_stardoc") bazel_dep(name = "rules_proto", version = "5.3.0-21.7") bazel_dep(name = "rules_testing", version = "0.5.0", dev_dependency = True) diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 81f27ccb4..b3ddb5f8f 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -9,4 +9,5 @@ sh_test( "kotlin.md", "//kotlin:stardoc", ], + tags = ["manual"], ) diff --git a/docs/kotlin.md b/docs/kotlin.md index 92411d23f..e7ed27e35 100755 --- a/docs/kotlin.md +++ b/docs/kotlin.md @@ -2,358 +2,380 @@ - + ## kt_javac_options +
+load("@rules_kotlin//kotlin:jvm.bzl", "kt_javac_options")
+
 kt_javac_options(name, add_exports, release, warn, x_ep_disable_all_checks, x_explicit_api_mode,
                  x_lint, xd_suppress_notes)
+
- - Define java compiler options for `kt_jvm_*` rules with java sources. - +Define java compiler options for `kt_jvm_*` rules with java sources. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|add_exports | Export internal jdk apis | List of strings | optional | [] | -|release | Compile for the specified Java SE release | String | optional | "default" | -|warn | Control warning behaviour. | String | optional | "report" | -|x_ep_disable_all_checks | See javac -XepDisableAllChecks documentation | Boolean | optional | False | -|x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | "off" | -|x_lint | See javac -Xlint: documentation | List of strings | optional | [] | -|xd_suppress_notes | See javac -XDsuppressNotes documentation | Boolean | optional | False | +| name | A unique name for this target. | Name | required | | +| add_exports | Export internal jdk apis | List of strings | optional | `[]` | +| release | Compile for the specified Java SE release | String | optional | `"default"` | +| warn | Control warning behaviour. | String | optional | `"report"` | +| x_ep_disable_all_checks | See javac -XepDisableAllChecks documentation | Boolean | optional | `False` | +| x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | `"off"` | +| x_lint | See javac -Xlint: documentation | List of strings | optional | `[]` | +| xd_suppress_notes | See javac -XDsuppressNotes documentation | Boolean | optional | `False` | - + ## kt_jvm_binary -kt_jvm_binary(name, associates, data, deps, javac_opts, jvm_flags, kotlinc_opts, main_class, - module_name, plugins, resource_jars, resource_strip_prefix, resources, runtime_deps, - srcs) +
+load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_binary")
+
+kt_jvm_binary(name, deps, srcs, data, resources, associates, javac_opts, jvm_flags, kotlinc_opts,
+              main_class, module_name, plugins, resource_jars, resource_strip_prefix, runtime_deps)
+
+ +Builds a Java archive ("jar file"), plus a wrapper shell script with the same name as the rule. The wrapper +shell script uses a classpath that includes, among other things, a jar file for each library on which the binary +depends. - - Builds a Java archive ("jar file"), plus a wrapper shell script with the same name as the rule. The wrapper - shell script uses a classpath that includes, among other things, a jar file for each library on which the binary - depends. - - **Note:** This rule does not have all of the features found in [`java_binary`](https://docs.bazel.build/versions/master/be/java.html#java_binary). - It is appropriate for building workspace utilities. `java_binary` should be preferred for release artefacts. - +**Note:** This rule does not have all of the features found in [`java_binary`](https://docs.bazel.build/versions/master/be/java.html#java_binary). +It is appropriate for building workspace utilities. `java_binary` should be preferred for release artefacts. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | List of labels | optional | [] | -|data | The list of files needed by this rule at runtime. See general comments about data at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] | -|deps | A list of dependencies of this rule.See general comments about deps at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] | -|javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None | -|jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet support make variable substitution. | List of strings | optional | [] | -|kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None | -|main_class | Name of class with main() method to use as entry point. | String | required | | -|module_name | The name of the module, if not provided the module name is derived from the label. --e.g., //some/package/path:label_name is translated to some_package_path-label_name. | String | optional | "" | -|plugins | - | List of labels | optional | [] | -|resource_jars | Set of archives containing Java resources. If specified, the contents of these jars are merged into the output jar. | List of labels | optional | [] | -|resource_strip_prefix | The path prefix to strip from Java resources, files residing under common prefix such as src/main/resources or src/test/resources or kotlin will have stripping applied by convention. | String | optional | "" | -|resources | A list of files that should be include in a Java jar. | List of labels | optional | [] | -|runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary deps, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. | List of labels | optional | [] | -|srcs | The list of source files that are processed to create the target, this can contain both Java and Kotlin files. Java analysis occurs first so Kotlin classes may depend on Java classes in the same compilation unit. | List of labels | optional | [] | - - - +| name | A unique name for this target. | Name | required | | +| deps | A list of dependencies of this rule.See general comments about `deps` at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | `[]` | +| srcs | The list of source files that are processed to create the target, this can contain both Java and Kotlin files. Java analysis occurs first so Kotlin classes may depend on Java classes in the same compilation unit. | List of labels | optional | `[]` | +| data | The list of files needed by this rule at runtime. See general comments about `data` at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | `[]` | +| resources | A list of files that should be include in a Java jar. | List of labels | optional | `[]` | +| associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | List of labels | optional | `[]` | +| javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | `None` | +| jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet support make variable substitution. | List of strings | optional | `[]` | +| kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | `None` | +| main_class | Name of class with main() method to use as entry point. | String | required | | +| module_name | The name of the module, if not provided the module name is derived from the label. --e.g., `//some/package/path:label_name` is translated to `some_package_path-label_name`. | String | optional | `""` | +| plugins | - | List of labels | optional | `[]` | +| resource_jars | Set of archives containing Java resources. If specified, the contents of these jars are merged into the output jar. | List of labels | optional | `[]` | +| resource_strip_prefix | The path prefix to strip from Java resources, files residing under common prefix such as `src/main/resources` or `src/test/resources` or `kotlin` will have stripping applied by convention. | String | optional | `""` | +| runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary deps, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. | List of labels | optional | `[]` | + + + ## kt_jvm_import +
+load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_import")
+
 kt_jvm_import(name, deps, exported_compiler_plugins, exports, jar, jars, neverlink, runtime_deps,
               srcjar)
+
- - Import Kotlin jars. - - ## examples - - ```bzl - # Old style usage -- reference file groups, do not used this. - kt_jvm_import( - name = "kodein", - jars = [ - "@com_github_salomonbrys_kodein_kodein//jar:file", - "@com_github_salomonbrys_kodein_kodein_core//jar:file" - ] - ) - - # This style will pull in the transitive runtime dependencies of the targets as well. - kt_jvm_import( - name = "kodein", - jars = [ - "@com_github_salomonbrys_kodein_kodein//jar", - "@com_github_salomonbrys_kodein_kodein_core//jar" - ] - ) - - # Import a single kotlin jar. - kt_jvm_import( - name = "kotlin-stdlib", - jars = ["lib/kotlin-stdlib.jar"], - srcjar = "lib/kotlin-stdlib-sources.jar" - ) - ``` - +Import Kotlin jars. + +## examples + +```bzl +# Old style usage -- reference file groups, do not used this. +kt_jvm_import( + name = "kodein", + jars = [ + "@com_github_salomonbrys_kodein_kodein//jar:file", + "@com_github_salomonbrys_kodein_kodein_core//jar:file" + ] +) + +# This style will pull in the transitive runtime dependencies of the targets as well. +kt_jvm_import( + name = "kodein", + jars = [ + "@com_github_salomonbrys_kodein_kodein//jar", + "@com_github_salomonbrys_kodein_kodein_core//jar" + ] +) + +# Import a single kotlin jar. +kt_jvm_import( + name = "kotlin-stdlib", + jars = ["lib/kotlin-stdlib.jar"], + srcjar = "lib/kotlin-stdlib-sources.jar" +) +``` **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|deps | Compile and runtime dependencies | List of labels | optional | [] | -|exported_compiler_plugins | Exported compiler plugins.

Compiler plugins listed here will be treated as if they were added in the plugins attribute of any targets that directly depend on this target. Unlike java_plugins' exported_plugins, this is not transitive | List of labels | optional | [] | -|exports | Exported libraries.

Deps listed here will be made available to other rules, as if the parents explicitly depended on these deps. This is not true for regular (non-exported) deps. | List of labels | optional | [] | -|jar | The jar listed here is equivalent to an export attribute. | Label | optional | None | -|jars | The jars listed here are equavalent to an export attribute. The label should be either to a single class jar, or one or more filegroup labels. The filegroups, when resolved, must contain only one jar containing classes, and (optionally) one peer file containing sources, named <jarname>-sources.jar.

DEPRECATED - please use jar and srcjar attributes. | List of labels | optional | [] | -|neverlink | If true only use this library for compilation and not at runtime. | Boolean | optional | False | -|runtime_deps | Additional runtime deps. | List of labels | optional | [] | -|srcjar | The sources for the class jar. | Label | optional | //third_party:empty.jar | +| name | A unique name for this target. | Name | required | | +| deps | Compile and runtime dependencies | List of labels | optional | `[]` | +| exported_compiler_plugins | Exported compiler plugins.

Compiler plugins listed here will be treated as if they were added in the plugins attribute of any targets that directly depend on this target. Unlike java_plugins' exported_plugins, this is not transitive | List of labels | optional | `[]` | +| exports | Exported libraries.

Deps listed here will be made available to other rules, as if the parents explicitly depended on these deps. This is not true for regular (non-exported) deps. | List of labels | optional | `[]` | +| jar | The jar listed here is equivalent to an export attribute. | Label | optional | `None` | +| jars | The jars listed here are equavalent to an export attribute. The label should be either to a single class jar, or one or more filegroup labels. The filegroups, when resolved, must contain only one jar containing classes, and (optionally) one peer file containing sources, named `-sources.jar`.

DEPRECATED - please use `jar` and `srcjar` attributes. | List of labels | optional | `[]` | +| neverlink | If true only use this library for compilation and not at runtime. | Boolean | optional | `False` | +| runtime_deps | Additional runtime deps. | List of labels | optional | `[]` | +| srcjar | The sources for the class jar. | Label | optional | `"@rules_kotlin//third_party:empty.jar"` | - + ## kt_jvm_library -kt_jvm_library(name, associates, data, deps, exported_compiler_plugins, exports, javac_opts, - kotlinc_opts, module_name, neverlink, plugins, resource_jars, resource_strip_prefix, - resources, runtime_deps, srcs) +
+load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
+
+kt_jvm_library(name, deps, srcs, data, resources, associates, exported_compiler_plugins, exports,
+               javac_opts, kotlinc_opts, module_name, neverlink, plugins, resource_jars,
+               resource_strip_prefix, runtime_deps)
+
- - This rule compiles and links Kotlin and Java sources into a .jar file. - +This rule compiles and links Kotlin and Java sources into a .jar file. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | List of labels | optional | [] | -|data | The list of files needed by this rule at runtime. See general comments about data at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] | -|deps | A list of dependencies of this rule.See general comments about deps at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] | -|exported_compiler_plugins | Exported compiler plugins.

Compiler plugins listed here will be treated as if they were added in the plugins attribute of any targets that directly depend on this target. Unlike java_plugins exported_plugins, this is not transitive | List of labels | optional | [] | -|exports | Exported libraries.

Deps listed here will be made available to other rules, as if the parents explicitly depended on these deps. This is not true for regular (non-exported) deps. | List of labels | optional | [] | -|javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None | -|kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None | -|module_name | The name of the module, if not provided the module name is derived from the label. --e.g., //some/package/path:label_name is translated to some_package_path-label_name. | String | optional | "" | -|neverlink | If true only use this library for compilation and not at runtime. | Boolean | optional | False | -|plugins | - | List of labels | optional | [] | -|resource_jars | Set of archives containing Java resources. If specified, the contents of these jars are merged into the output jar. | List of labels | optional | [] | -|resource_strip_prefix | The path prefix to strip from Java resources, files residing under common prefix such as src/main/resources or src/test/resources or kotlin will have stripping applied by convention. | String | optional | "" | -|resources | A list of files that should be include in a Java jar. | List of labels | optional | [] | -|runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary deps, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. | List of labels | optional | [] | -|srcs | The list of source files that are processed to create the target, this can contain both Java and Kotlin files. Java analysis occurs first so Kotlin classes may depend on Java classes in the same compilation unit. | List of labels | optional | [] | - - - +| name | A unique name for this target. | Name | required | | +| deps | A list of dependencies of this rule.See general comments about `deps` at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | `[]` | +| srcs | The list of source files that are processed to create the target, this can contain both Java and Kotlin files. Java analysis occurs first so Kotlin classes may depend on Java classes in the same compilation unit. | List of labels | optional | `[]` | +| data | The list of files needed by this rule at runtime. See general comments about `data` at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | `[]` | +| resources | A list of files that should be include in a Java jar. | List of labels | optional | `[]` | +| associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | List of labels | optional | `[]` | +| exported_compiler_plugins | Exported compiler plugins.

Compiler plugins listed here will be treated as if they were added in the plugins attribute of any targets that directly depend on this target. Unlike `java_plugin`s exported_plugins, this is not transitive | List of labels | optional | `[]` | +| exports | Exported libraries.

Deps listed here will be made available to other rules, as if the parents explicitly depended on these deps. This is not true for regular (non-exported) deps. | List of labels | optional | `[]` | +| javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | `None` | +| kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | `None` | +| module_name | The name of the module, if not provided the module name is derived from the label. --e.g., `//some/package/path:label_name` is translated to `some_package_path-label_name`. | String | optional | `""` | +| neverlink | If true only use this library for compilation and not at runtime. | Boolean | optional | `False` | +| plugins | - | List of labels | optional | `[]` | +| resource_jars | Set of archives containing Java resources. If specified, the contents of these jars are merged into the output jar. | List of labels | optional | `[]` | +| resource_strip_prefix | The path prefix to strip from Java resources, files residing under common prefix such as `src/main/resources` or `src/test/resources` or `kotlin` will have stripping applied by convention. | String | optional | `""` | +| runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary deps, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. | List of labels | optional | `[]` | + + + ## kt_jvm_test -kt_jvm_test(name, associates, data, deps, env, javac_opts, jvm_flags, kotlinc_opts, main_class, - module_name, plugins, resource_jars, resource_strip_prefix, resources, runtime_deps, srcs, +
+load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test")
+
+kt_jvm_test(name, deps, srcs, data, resources, associates, env, javac_opts, jvm_flags, kotlinc_opts,
+            main_class, module_name, plugins, resource_jars, resource_strip_prefix, runtime_deps,
             test_class)
+
+ +Setup a simple kotlin_test. - - Setup a simple kotlin_test. - - **Notes:** - * The kotlin test library is not added implicitly, it is available with the label - `@rules_kotlin//kotlin/compiler:kotlin-test`. - +**Notes:** +* The kotlin test library is not added implicitly, it is available with the label +`@rules_kotlin//kotlin/compiler:kotlin-test`. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | List of labels | optional | [] | -|data | The list of files needed by this rule at runtime. See general comments about data at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] | -|deps | A list of dependencies of this rule.See general comments about deps at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | [] | -|env | Specifies additional environment variables to set when the target is executed by bazel test. | Dictionary: String -> String | optional | {} | -|javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None | -|jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet support make variable substitution. | List of strings | optional | [] | -|kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | None | -|main_class | - | String | optional | "com.google.testing.junit.runner.BazelTestRunner" | -|module_name | The name of the module, if not provided the module name is derived from the label. --e.g., //some/package/path:label_name is translated to some_package_path-label_name. | String | optional | "" | -|plugins | - | List of labels | optional | [] | -|resource_jars | Set of archives containing Java resources. If specified, the contents of these jars are merged into the output jar. | List of labels | optional | [] | -|resource_strip_prefix | The path prefix to strip from Java resources, files residing under common prefix such as src/main/resources or src/test/resources or kotlin will have stripping applied by convention. | String | optional | "" | -|resources | A list of files that should be include in a Java jar. | List of labels | optional | [] | -|runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary deps, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. | List of labels | optional | [] | -|srcs | The list of source files that are processed to create the target, this can contain both Java and Kotlin files. Java analysis occurs first so Kotlin classes may depend on Java classes in the same compilation unit. | List of labels | optional | [] | -|test_class | The Java class to be loaded by the test runner. | String | optional | "" | +| name | A unique name for this target. | Name | required | | +| deps | A list of dependencies of this rule.See general comments about `deps` at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | `[]` | +| srcs | The list of source files that are processed to create the target, this can contain both Java and Kotlin files. Java analysis occurs first so Kotlin classes may depend on Java classes in the same compilation unit. | List of labels | optional | `[]` | +| data | The list of files needed by this rule at runtime. See general comments about `data` at [Attributes common to all build rules](https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes). | List of labels | optional | `[]` | +| resources | A list of files that should be include in a Java jar. | List of labels | optional | `[]` | +| associates | Kotlin deps who should be considered part of the same module/compilation-unit for the purposes of "internal" access. Such deps must all share the same module space and so a target cannot associate to two deps from two different modules. | List of labels | optional | `[]` | +| env | Specifies additional environment variables to set when the target is executed by bazel test. | Dictionary: String -> String | optional | `{}` | +| javac_opts | Javac options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | `None` | +| jvm_flags | A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet support make variable substitution. | List of strings | optional | `[]` | +| kotlinc_opts | Kotlinc options to be used when compiling this target. These opts if provided will be used instead of the ones provided to the toolchain. | Label | optional | `None` | +| main_class | - | String | optional | `"com.google.testing.junit.runner.BazelTestRunner"` | +| module_name | The name of the module, if not provided the module name is derived from the label. --e.g., `//some/package/path:label_name` is translated to `some_package_path-label_name`. | String | optional | `""` | +| plugins | - | List of labels | optional | `[]` | +| resource_jars | Set of archives containing Java resources. If specified, the contents of these jars are merged into the output jar. | List of labels | optional | `[]` | +| resource_strip_prefix | The path prefix to strip from Java resources, files residing under common prefix such as `src/main/resources` or `src/test/resources` or `kotlin` will have stripping applied by convention. | String | optional | `""` | +| runtime_deps | Libraries to make available to the final binary or test at runtime only. Like ordinary deps, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. | List of labels | optional | `[]` | +| test_class | The Java class to be loaded by the test runner. | String | optional | `""` | - + ## ktlint_config +
+load("@rules_kotlin//kotlin:lint.bzl", "ktlint_config")
+
 ktlint_config(name, android_rules_enabled, editorconfig, experimental_rules_enabled)
+
- - Used to configure ktlint. - - `ktlint` can be configured to use a `.editorconfig`, as documented at - https://github.com/pinterest/ktlint/#editorconfig - +Used to configure ktlint. + +`ktlint` can be configured to use a `.editorconfig`, as documented at +https://github.com/pinterest/ktlint/#editorconfig **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|android_rules_enabled | Turn on Android Kotlin Style Guide compatibility | Boolean | optional | False | -|editorconfig | Editor config file to use | Label | optional | None | -|experimental_rules_enabled | Turn on experimental rules (ktlint-ruleset-experimental) | Boolean | optional | False | +| name | A unique name for this target. | Name | required | | +| android_rules_enabled | Turn on Android Kotlin Style Guide compatibility | Boolean | optional | `False` | +| editorconfig | Editor config file to use | Label | optional | `None` | +| experimental_rules_enabled | Turn on experimental rules (ktlint-ruleset-experimental) | Boolean | optional | `False` | - + ## ktlint_fix -ktlint_fix(name, config, srcs) +
+load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix")
+
+ktlint_fix(name, srcs, config)
+
- - Lint Kotlin files and automatically fix them as needed - +Lint Kotlin files and automatically fix them as needed **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|config | ktlint_config to use | Label | optional | None | -|srcs | Source files to review and fix | List of labels | required | | +| name | A unique name for this target. | Name | required | | +| srcs | Source files to review and fix | List of labels | required | | +| config | ktlint_config to use | Label | optional | `None` | - + ## ktlint_test -ktlint_test(name, config, srcs) +
+load("@rules_kotlin//kotlin:lint.bzl", "ktlint_test")
 
-                                                                                                
-    Lint Kotlin files, and fail if the linter raises errors.
-    
+ktlint_test(name, srcs, config)
+
+ +Lint Kotlin files, and fail if the linter raises errors. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|config | ktlint_config to use | Label | optional | None | -|srcs | Source files to lint | List of labels | required | | +| name | A unique name for this target. | Name | required | | +| srcs | Source files to lint | List of labels | required | | +| config | ktlint_config to use | Label | optional | `None` | - + ## kt_compiler_plugin -kt_compiler_plugin(name, compile_phase, deps, id, options, stubs_phase, target_embedded_compiler) - - - Define a plugin for the Kotlin compiler to run. The plugin can then be referenced in the `plugins` attribute - of the `kt_jvm_*` rules. - - An example can be found under `//examples/plugin`: - - ```bzl - kt_compiler_plugin( - name = "open_for_testing_plugin", - id = "org.jetbrains.kotlin.allopen", - options = { - "annotation": "plugin.OpenForTesting", - }, - deps = [ - "//kotlin/compiler:allopen-compiler-plugin", - ], - ) - - kt_jvm_library( - name = "open_for_testing", - srcs = ["OpenForTesting.kt"], - ) - - kt_jvm_library( - name = "user", - srcs = ["User.kt"], - plugins = [":open_for_testing_plugin"], - deps = [ - ":open_for_testing", - ], - ) - ``` - +
+load("@rules_kotlin//kotlin:core.bzl", "kt_compiler_plugin")
+
+kt_compiler_plugin(name, deps, compile_phase, id, options, stubs_phase, target_embedded_compiler)
+
+ +Define a plugin for the Kotlin compiler to run. The plugin can then be referenced in the `plugins` attribute +of the `kt_jvm_*` rules. + +An example can be found under `//examples/plugin`: + +```bzl +kt_compiler_plugin( + name = "open_for_testing_plugin", + id = "org.jetbrains.kotlin.allopen", + options = { + "annotation": "plugin.OpenForTesting", + }, + deps = [ + "//kotlin/compiler:allopen-compiler-plugin", + ], +) + +kt_jvm_library( + name = "open_for_testing", + srcs = ["OpenForTesting.kt"], +) + +kt_jvm_library( + name = "user", + srcs = ["User.kt"], + plugins = [":open_for_testing_plugin"], + deps = [ + ":open_for_testing", + ], +) +``` **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|compile_phase | Runs the compiler plugin during kotlin compilation. Known examples: allopen, sam_with_reciever | Boolean | optional | True | -|deps | The list of libraries to be added to the compiler's plugin classpath | List of labels | optional | [] | -|id | The ID of the plugin | String | required | | -|options | Dictionary of options to be passed to the plugin. Supports the following template values:

- {generatedClasses}: directory for generated class output - {temp}: temporary directory, discarded between invocations - {generatedSources}: directory for generated source output - {classpath} : replaced with a list of jars separated by the filesystem appropriate separator. | Dictionary: String -> String | optional | {} | -|stubs_phase | Runs the compiler plugin in kapt stub generation. | Boolean | optional | True | -|target_embedded_compiler | Plugin was compiled against the embeddable kotlin compiler. These plugins expect shaded kotlinc dependencies, and will fail when running against a non-embeddable compiler. | Boolean | optional | False | +| name | A unique name for this target. | Name | required | | +| deps | The list of libraries to be added to the compiler's plugin classpath | List of labels | optional | `[]` | +| compile_phase | Runs the compiler plugin during kotlin compilation. Known examples: `allopen`, `sam_with_reciever` | Boolean | optional | `True` | +| id | The ID of the plugin | String | required | | +| options | Dictionary of options to be passed to the plugin. Supports the following template values:

- `{generatedClasses}`: directory for generated class output - `{temp}`: temporary directory, discarded between invocations - `{generatedSources}`: directory for generated source output - `{classpath}` : replaced with a list of jars separated by the filesystem appropriate separator. | Dictionary: String -> String | optional | `{}` | +| stubs_phase | Runs the compiler plugin in kapt stub generation. | Boolean | optional | `True` | +| target_embedded_compiler | Plugin was compiled against the embeddable kotlin compiler. These plugins expect shaded kotlinc dependencies, and will fail when running against a non-embeddable compiler. | Boolean | optional | `False` | - + ## kt_javac_options +
+load("@rules_kotlin//kotlin:core.bzl", "kt_javac_options")
+
 kt_javac_options(name, add_exports, release, warn, x_ep_disable_all_checks, x_explicit_api_mode,
                  x_lint, xd_suppress_notes)
+
- - Define java compiler options for `kt_jvm_*` rules with java sources. - +Define java compiler options for `kt_jvm_*` rules with java sources. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|add_exports | Export internal jdk apis | List of strings | optional | [] | -|release | Compile for the specified Java SE release | String | optional | "default" | -|warn | Control warning behaviour. | String | optional | "report" | -|x_ep_disable_all_checks | See javac -XepDisableAllChecks documentation | Boolean | optional | False | -|x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | "off" | -|x_lint | See javac -Xlint: documentation | List of strings | optional | [] | -|xd_suppress_notes | See javac -XDsuppressNotes documentation | Boolean | optional | False | +| name | A unique name for this target. | Name | required | | +| add_exports | Export internal jdk apis | List of strings | optional | `[]` | +| release | Compile for the specified Java SE release | String | optional | `"default"` | +| warn | Control warning behaviour. | String | optional | `"report"` | +| x_ep_disable_all_checks | See javac -XepDisableAllChecks documentation | Boolean | optional | `False` | +| x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | `"off"` | +| x_lint | See javac -Xlint: documentation | List of strings | optional | `[]` | +| xd_suppress_notes | See javac -XDsuppressNotes documentation | Boolean | optional | `False` | - + ## kt_kotlinc_options +
+load("@rules_kotlin//kotlin:core.bzl", "kt_kotlinc_options")
+
 kt_kotlinc_options(name, include_stdlibs, java_parameters, jvm_target, warn,
                    x_allow_result_return_type, x_assertions, x_backend_threads, x_context_receivers,
                    x_emit_jvm_type_annotations, x_enable_incremental_compilation, x_explicit_api_mode,
@@ -363,116 +385,117 @@ kt_kotlinc_options(name, x_no_receiver_assertions, x_no_source_debug_extension, x_optin, x_report_perf,
                    x_sam_conversions, x_skip_prerelease_check, x_suppress_version_warnings,
                    x_type_enhancement_improvements_strict_mode, x_use_fir_lt, x_use_k2)
+
- - Define kotlin compiler options. - +Define kotlin compiler options. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|include_stdlibs | Don't automatically include the Kotlin standard libraries into the classpath (stdlib and reflect). | String | optional | "all" | -|java_parameters | Generate metadata for Java 1.8+ reflection on method parameters. | Boolean | optional | False | -|jvm_target | The -jvm_target flag. This is only tested at 1.8. | String | optional | "" | -|warn | Control warning behaviour. | String | optional | "report" | -|x_allow_result_return_type | Enable kotlin.Result as a return type | Boolean | optional | False | -|x_assertions | Configures how assertions are handled. The 'jvm' option enables assertions in JVM code. | String | optional | "" | -|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 | -|x_context_receivers | Enable experimental context receivers. | Boolean | optional | False | -|x_emit_jvm_type_annotations | Basic support for type annotations in JVM bytecode. | Boolean | optional | False | -|x_enable_incremental_compilation | Enable incremental compilation | Boolean | optional | False | -|x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | "off" | -|x_inline_classes | Enable experimental inline classes | Boolean | optional | False | -|x_jdk_release | The -jvm_target flag. This is only tested at 1.8. | String | optional | "" | -|x_jspecify_annotations | Controls how JSpecify annotations are treated. Options are 'default', 'ignore', 'warn', and 'strict'. | String | optional | "" | -|x_jsr_305 | Specifies how to handle JSR-305 annotations in Kotlin code. Options are 'default', 'ignore', 'warn', and 'strict'. | String | optional | "" | -|x_jvm_default | Specifies that a JVM default method should be generated for non-abstract Kotlin interface member. | String | optional | "off" | -|x_lambdas | Change codegen behavior of lambdas | String | optional | "class" | -|x_multi_platform | Enable experimental language support for multi-platform projects | Boolean | optional | False | -|x_no_call_assertions | Don't generate not-null assertions for arguments of platform types | Boolean | optional | False | -|x_no_optimize | Disable optimizations | Boolean | optional | False | -|x_no_optimized_callable_references | Do not use optimized callable reference superclasses. Available from 1.4. | Boolean | optional | False | -|x_no_param_assertions | Don't generate not-null assertions on parameters of methods accessible from Java | Boolean | optional | False | -|x_no_receiver_assertions | Don't generate not-null assertion for extension receiver arguments of platform types | Boolean | optional | False | -|x_no_source_debug_extension | Do not generate @kotlin.jvm.internal.SourceDebugExtension annotation on a class with the copy of SMAP | Boolean | optional | False | -|x_optin | Define APIs to opt-in to. | List of strings | optional | [] | -|x_report_perf | Report detailed performance statistics | Boolean | optional | False | -|x_sam_conversions | Change codegen behavior of SAM/functional interfaces | String | optional | "class" | -|x_skip_prerelease_check | Suppress errors thrown when using pre-release classes. | Boolean | optional | False | -|x_suppress_version_warnings | Suppress warnings about outdated, inconsistent, or experimental language or API versions. | Boolean | optional | False | -|x_type_enhancement_improvements_strict_mode | Enables strict mode for type enhancement improvements, enforcing stricter type checking and enhancements. | Boolean | optional | False | -|x_use_fir_lt | Compile using LightTree parser with Front-end IR. Warning: this feature is far from being production-ready | Boolean | optional | False | -|x_use_k2 | Compile using experimental K2. K2 is a new compiler pipeline, no compatibility guarantees are yet provided | Boolean | optional | False | - - - +| name | A unique name for this target. | Name | required | | +| include_stdlibs | Don't automatically include the Kotlin standard libraries into the classpath (stdlib and reflect). | String | optional | `"all"` | +| java_parameters | Generate metadata for Java 1.8+ reflection on method parameters. | Boolean | optional | `False` | +| jvm_target | The -jvm_target flag. This is only tested at 1.8. | String | optional | `""` | +| warn | Control warning behaviour. | String | optional | `"report"` | +| x_allow_result_return_type | Enable kotlin.Result as a return type | Boolean | optional | `False` | +| x_assertions | Configures how assertions are handled. The 'jvm' option enables assertions in JVM code. | String | optional | `""` | +| 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` | +| x_context_receivers | Enable experimental context receivers. | Boolean | optional | `False` | +| x_emit_jvm_type_annotations | Basic support for type annotations in JVM bytecode. | Boolean | optional | `False` | +| x_enable_incremental_compilation | Enable incremental compilation | Boolean | optional | `False` | +| x_explicit_api_mode | Enable explicit API mode for Kotlin libraries. | String | optional | `"off"` | +| x_inline_classes | Enable experimental inline classes | Boolean | optional | `False` | +| x_jdk_release | The -jvm_target flag. This is only tested at 1.8. | String | optional | `""` | +| x_jspecify_annotations | Controls how JSpecify annotations are treated. Options are 'default', 'ignore', 'warn', and 'strict'. | String | optional | `""` | +| x_jsr_305 | Specifies how to handle JSR-305 annotations in Kotlin code. Options are 'default', 'ignore', 'warn', and 'strict'. | String | optional | `""` | +| x_jvm_default | Specifies that a JVM default method should be generated for non-abstract Kotlin interface member. | String | optional | `"off"` | +| x_lambdas | Change codegen behavior of lambdas | String | optional | `"class"` | +| x_multi_platform | Enable experimental language support for multi-platform projects | Boolean | optional | `False` | +| x_no_call_assertions | Don't generate not-null assertions for arguments of platform types | Boolean | optional | `False` | +| x_no_optimize | Disable optimizations | Boolean | optional | `False` | +| x_no_optimized_callable_references | Do not use optimized callable reference superclasses. Available from 1.4. | Boolean | optional | `False` | +| x_no_param_assertions | Don't generate not-null assertions on parameters of methods accessible from Java | Boolean | optional | `False` | +| x_no_receiver_assertions | Don't generate not-null assertion for extension receiver arguments of platform types | Boolean | optional | `False` | +| x_no_source_debug_extension | Do not generate @kotlin.jvm.internal.SourceDebugExtension annotation on a class with the copy of SMAP | Boolean | optional | `False` | +| x_optin | Define APIs to opt-in to. | List of strings | optional | `[]` | +| x_report_perf | Report detailed performance statistics | Boolean | optional | `False` | +| x_sam_conversions | Change codegen behavior of SAM/functional interfaces | String | optional | `"class"` | +| x_skip_prerelease_check | Suppress errors thrown when using pre-release classes. | Boolean | optional | `False` | +| x_suppress_version_warnings | Suppress warnings about outdated, inconsistent, or experimental language or API versions. | Boolean | optional | `False` | +| x_type_enhancement_improvements_strict_mode | Enables strict mode for type enhancement improvements, enforcing stricter type checking and enhancements. | Boolean | optional | `False` | +| x_use_fir_lt | Compile using LightTree parser with Front-end IR. Warning: this feature is far from being production-ready | Boolean | optional | `False` | +| x_use_k2 | Compile using experimental K2. K2 is a new compiler pipeline, no compatibility guarantees are yet provided | Boolean | optional | `False` | + + + ## kt_ksp_plugin +
+load("@rules_kotlin//kotlin:core.bzl", "kt_ksp_plugin")
+
 kt_ksp_plugin(name, deps, generates_java, processor_class, target_embedded_compiler)
+
+ +Define a KSP plugin for the Kotlin compiler to run. The plugin can then be referenced in the `plugins` attribute +of the `kt_jvm_*` and `kt_android_*` rules. + +An example can be found under `//examples/ksp`: - - Define a KSP plugin for the Kotlin compiler to run. The plugin can then be referenced in the `plugins` attribute - of the `kt_jvm_*` and `kt_android_*` rules. - - An example can be found under `//examples/ksp`: - - ```bzl - kt_ksp_plugin( - name = "moshi-kotlin-codegen", - processor_class = "com.squareup.moshi.kotlin.codegen.ksp.JsonClassSymbolProcessorProvider", - deps = [ - "@maven//:com_squareup_moshi_moshi", - "@maven//:com_squareup_moshi_moshi_kotlin", - "@maven//:com_squareup_moshi_moshi_kotlin_codegen", - ], - ) - - kt_jvm_library( - name = "lib", - srcs = glob(["*.kt"]), - plugins = ["//:moshi-kotlin-codegen"], - ) - +```bzl +kt_ksp_plugin( + name = "moshi-kotlin-codegen", + processor_class = "com.squareup.moshi.kotlin.codegen.ksp.JsonClassSymbolProcessorProvider", + deps = [ + "@maven//:com_squareup_moshi_moshi", + "@maven//:com_squareup_moshi_moshi_kotlin", + "@maven//:com_squareup_moshi_moshi_kotlin_codegen", + ], +) + +kt_jvm_library( + name = "lib", + srcs = glob(["*.kt"]), + plugins = ["//:moshi-kotlin-codegen"], +) **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|deps | The list of libraries to be added to the compiler's plugin classpath | List of labels | optional | [] | -|generates_java | Runs Java compilation action for plugin generating Java output. | Boolean | optional | False | -|processor_class | The fully qualified class name that the Java compiler uses as an entry point to the annotation processor. | String | required | | -|target_embedded_compiler | Plugin was compiled against the embeddable kotlin compiler. These plugins expect shaded kotlinc dependencies, and will fail when running against a non-embeddable compiler. | Boolean | optional | False | +| name | A unique name for this target. | Name | required | | +| deps | The list of libraries to be added to the compiler's plugin classpath | List of labels | optional | `[]` | +| generates_java | Runs Java compilation action for plugin generating Java output. | Boolean | optional | `False` | +| processor_class | The fully qualified class name that the Java compiler uses as an entry point to the annotation processor. | String | required | | +| target_embedded_compiler | Plugin was compiled against the embeddable kotlin compiler. These plugins expect shaded kotlinc dependencies, and will fail when running against a non-embeddable compiler. | Boolean | optional | `False` | - + ## kt_plugin_cfg +
+load("@rules_kotlin//kotlin:core.bzl", "kt_plugin_cfg")
+
 kt_plugin_cfg(name, deps, options, plugin)
+
+ +Configurations for kt_compiler_plugin, ksp_plugin, and java_plugin. - - - Configurations for kt_compiler_plugin, ksp_plugin, and java_plugin. - - This allows setting options and dependencies independently from the initial plugin definition. - - +This allows setting options and dependencies independently from the initial plugin definition. **ATTRIBUTES** | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | -|name | A unique name for this target. | Name | required | | -|deps | Dependencies for this configuration. | List of labels | optional | [] | -|options | A dictionary of flag to values to be used as plugin configuration options. | Dictionary: String -> List of strings | optional | {} | -|plugin | The plugin to associate with this configuration | Label | required | | +| name | A unique name for this target. | Name | required | | +| deps | Dependencies for this configuration. | List of labels | optional | `[]` | +| options | A dictionary of flag to values to be used as plugin configuration options. | Dictionary: String -> List of strings | optional | `{}` | +| plugin | The plugin to associate with this configuration | Label | required | | @@ -480,6 +503,8 @@ kt_plugin_cfg(name, name, language_version, api_version, jvm_target, experimental_use_abi_jars, experimental_strict_kotlin_deps, experimental_report_unused_deps, experimental_reduce_classpath_mode, experimental_multiplex_workers, javac_options, @@ -495,20 +520,20 @@ Define the Kotlin toolchain. | Name | Description | Default Value | | :------------- | :------------- | :------------- | | name |

-

| none | -| language_version |

-

| None | -| api_version |

-

| None | -| jvm_target |

-

| None | -| experimental_use_abi_jars |

-

| False | -| experimental_strict_kotlin_deps |

-

| None | -| experimental_report_unused_deps |

-

| None | -| experimental_reduce_classpath_mode |

-

| None | -| experimental_multiplex_workers |

-

| None | -| javac_options |

-

| Label("//kotlin/internal:default_javac_options") | -| kotlinc_options |

-

| Label("//kotlin/internal:default_kotlinc_options") | -| jacocorunner |

-

| None | -| exec_compatible_with |

-

| None | -| target_compatible_with |

-

| None | -| target_settings |

-

| None | +| language_version |

-

| `None` | +| api_version |

-

| `None` | +| jvm_target |

-

| `None` | +| experimental_use_abi_jars |

-

| `False` | +| experimental_strict_kotlin_deps |

-

| `None` | +| experimental_report_unused_deps |

-

| `None` | +| experimental_reduce_classpath_mode |

-

| `None` | +| experimental_multiplex_workers |

-

| `None` | +| javac_options |

-

| `Label("@rules_kotlin//kotlin/internal:default_javac_options")` | +| kotlinc_options |

-

| `Label("@rules_kotlin//kotlin/internal:default_kotlinc_options")` | +| jacocorunner |

-

| `None` | +| exec_compatible_with |

-

| `None` | +| target_compatible_with |

-

| `None` | +| target_settings |

-

| `None` | @@ -516,6 +541,8 @@ Define the Kotlin toolchain. ## kt_register_toolchains
+load("@rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
+
 kt_register_toolchains()
 
@@ -532,6 +559,8 @@ This macro registers the kotlin toolchain. ## kotlin_repositories
+load("@rules_kotlin//kotlin:repositories.doc.bzl", "kotlin_repositories")
+
 kotlin_repositories(is_bzlmod, compiler_repository_name, ksp_repository_name, compiler_release,
                     ksp_compiler_release)
 
@@ -543,11 +572,11 @@ Call this in the WORKSPACE file to setup the Kotlin rules. | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| is_bzlmod |

-

| False | -| compiler_repository_name | for the kotlinc compiler repository. | "com_github_jetbrains_kotlin" | -| ksp_repository_name |

-

| "com_github_google_ksp" | -| compiler_release | version provider from versions.bzl. | struct() | -| ksp_compiler_release | (internal) version provider from versions.bzl. | struct() | +| is_bzlmod |

-

| `False` | +| compiler_repository_name | for the kotlinc compiler repository. | `"com_github_jetbrains_kotlin"` | +| ksp_repository_name |

-

| `"com_github_google_ksp"` | +| compiler_release | version provider from versions.bzl. | `struct(sha256 = "ef578730976154fd2c5968d75af8c2703b3de84a78dffe913f670326e149da3b", url_templates = ["https://github.com/JetBrains/kotlin/releases/download/v{version}/kotlin-compiler-{version}.zip"], version = "2.0.0")` | +| ksp_compiler_release | (internal) version provider from versions.bzl. | `struct(sha256 = "84100aed5b63effa992ce6574b3ba47d2dbb78529752daa4c181e203117ba7de", url_templates = ["https://github.com/google/ksp/releases/download/{version}/artifacts.zip"], version = "2.0.0-1.0.21")` | @@ -555,6 +584,8 @@ Call this in the WORKSPACE file to setup the Kotlin rules. ## versions.use_repository
+load("@rules_kotlin//kotlin:repositories.doc.bzl", "versions")
+
 versions.use_repository(name, version, rule, kwargs)
 
diff --git a/examples/BUILD b/examples/BUILD index 1f74ee63a..6c71273a0 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -77,8 +77,8 @@ genrule( "*", # Node is currently broken. "node/**", - # Jetpack compose is in an ambigious state due to the android rules migration - #"jetpack_compose/**", + # Anvil is broken by a verison upgrade. + "anvil/**", ], ) } diff --git a/kotlin/BUILD b/kotlin/BUILD index 9b7f751f1..115469fc7 100644 --- a/kotlin/BUILD +++ b/kotlin/BUILD @@ -40,7 +40,6 @@ release_archive( name = doc, out = "%s.md" % doc, input = "%s.bzl" % doc, - rule_template = "//kotlin:doc-templates/rule.vm", deps = [ "//kotlin/internal", ], diff --git a/kotlin/doc-templates/rule.vm b/kotlin/doc-templates/rule.vm deleted file mode 100644 index 9025a374b..000000000 --- a/kotlin/doc-templates/rule.vm +++ /dev/null @@ -1,43 +0,0 @@ - - -#[[##]]# ${ruleName} - -${util.ruleSummary($ruleName, $ruleInfo)} - -## find common nonzero indent -#set($chomp=0) -#foreach ($ln in $ruleInfo.docString.split("\n")) - #if ($ln.length() > 0) - #foreach ($c in [0..$ln.length()]) - #if (!$ln.substring(0, $c).trim().isEmpty()) - #if ($chomp == 0) - #set($chomp = $c - 1) - #elseif($c < $chomp) - #set($chomp=$c - 1) - #end - #break - #end - #end - #end -#end - -## print lines, removing common indent. -#foreach ($ln in $ruleInfo.docString.split("\n")) - #if ($ln.length() >= $chomp && $ln.substring(0, $chomp).trim().isEmpty()) -${ln.substring($chomp)} - #else - ${ln} - #end -#end - - -**ATTRIBUTES** - -#if (!$ruleInfo.getAttributeList().isEmpty()) - -| Name | Description | Type | Mandatory | Default | -| :------------- | :------------- | :------------- | :------------- | :------------- | -#foreach ($attribute in $ruleInfo.getAttributeList()) -|$attribute.name | #if(!$attribute.docString.isEmpty()) ${util.markdownCellFormat($attribute.docString)} #else - #end | ${util.attributeTypeString($attribute)} | ${util.mandatoryString($attribute)} | $attribute.defaultValue | -#end -#end