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 |
+|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 | "" |
+|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 | [] |
+|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 | [] |
@@ -117,19 +116,19 @@ kt_jvm_import(name, exported_compiler_plugins | Exported compiler plugins.<jarname>-sources.jar
.jar
and srcjar
attributes. | List of labels | optional | [] |
+|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 `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.java_plugin
s exported_plugins, this is not transitive | 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 | [] |
+|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.//some/package/path:label_name
is translated to some_package_path-label_name
. | 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 |
+|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 | [] |
+|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,
+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)
@@ -180,21 +179,21 @@ kt_jvm_test(name, 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 | [] |
+|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 |
+|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 | "" |
+|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 | [] |
+|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 | "" |
@@ -208,9 +207,9 @@ kt_jvm_test(name, name, android_rules_enabled, editorconfig, experimental_rules_enabled)
-
- Used to configure ktlint.
-
+
+ Used to configure ktlint.
+
`ktlint` can be configured to use a `.editorconfig`, as documented at
https://github.com/pinterest/ktlint/#editorconfig
@@ -230,7 +229,7 @@ ktlint_config(name, name, config, srcs)
+ktlint_fix(name, srcs, config)
Lint Kotlin files and automatically fix them as needed
@@ -242,15 +241,15 @@ ktlint_fix(name, con
| 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 | |
+|config | ktlint_config to use | Label | optional | None |
## ktlint_test
-ktlint_test(name, config, srcs)
+ktlint_test(name, srcs, config)
Lint Kotlin files, and fail if the linter raises errors.
@@ -262,8 +261,8 @@ ktlint_test(name,
| 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 | |
+|config | ktlint_config to use | Label | optional | None |
@@ -274,7 +273,7 @@ ktlint_test(name,
## kt_compiler_plugin
-kt_compiler_plugin(name, compile_phase, deps, id, options, stubs_phase, target_embedded_compiler)
+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
@@ -316,12 +315,12 @@ kt_compiler_plugin(name, 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 | [] |
+|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 | {} |
+|options | Dictionary of options to be passed to the plugin. Supports the following template values:-
| 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
|
+| 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` | @@ -512,6 +511,8 @@ Define the Kotlin toolchain. ## kt_register_toolchains+load("@rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") + kt_register_toolchains()@@ -528,6 +529,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)@@ -539,11 +542,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")` | @@ -551,7 +554,9 @@ Call this in the WORKSPACE file to setup the Kotlin rules. ## versions.use_repository-versions.use_repository(name, version, rule, kwargs) +load("@rules_kotlin//kotlin:repositories.doc.bzl", "versions") + +versions.use_repository(name, version, rule, **kwargs)diff --git a/kotlin/doc-templates/rule.vm b/kotlin/doc-templates/rule.vm index 9025a374b..1f68a4885 100644 --- a/kotlin/doc-templates/rule.vm +++ b/kotlin/doc-templates/rule.vm @@ -6,7 +6,10 @@ ${util.ruleSummary($ruleName, $ruleInfo)} ## find common nonzero indent #set($chomp=0) -#foreach ($ln in $ruleInfo.docString.split("\n")) +## > Stardoc 6.0.0 The Markdown renderer now uses Google EscapeVelocity instead of Apache Velocity for templating. +## No more \n in templating rules. :/ +#foreach ($ln in $ruleInfo.docString.split(" +")) #if ($ln.length() > 0) #foreach ($c in [0..$ln.length()]) #if (!$ln.substring(0, $c).trim().isEmpty()) @@ -22,7 +25,10 @@ ${util.ruleSummary($ruleName, $ruleInfo)} #end ## print lines, removing common indent. -#foreach ($ln in $ruleInfo.docString.split("\n")) +## > Stardoc 6.0.0 The Markdown renderer now uses Google EscapeVelocity instead of Apache Velocity for templating. +## No more \n in templating rules. :/ +#foreach ($ln in $ruleInfo.docString.split(" +")) #if ($ln.length() >= $chomp && $ln.substring(0, $chomp).trim().isEmpty()) ${ln.substring($chomp)} #else