rules_kotlin
rules_kotlin copied to clipboard
add KAPT arguments to define_kt_toolchain
Adding KAPT arguments to define_kt_toolchain
By this, we can configure KAPT.
Build.bazel
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "define_kt_toolchain", "kapt_options")
kapt_options(
name = "kapt_options",
correctErrorTypes = True,
)
define_kt_toolchain(
name = "kotlin_toolchain",
api_version = "1.6",
experimental_multiplex_workers = True,
experimental_report_unused_deps = "off",
experimental_strict_kotlin_deps = "off",
experimental_use_abi_jars = True,
jvm_target = "11",
kapt_args = "//:kapt_options",
language_version = "1.6",
)
Notes:
All available options: https://kotlinlang.org/docs/kapt.html#using-in-cli
Kapt is in maintenance mode at the moment hence we could consider adding options statically as it is not expected to change much between versions. The structure outlined in this PR is similar to what is already done in Kotlin Gradle Plugin for example, the kapt {}
kapt {
showProcessorStats = true
correctErrorTypes = true
}
If this structure is accepted we could look into adding support for showProcessorStats as well via -Kapt-dump-processor-timings https://github.com/JetBrains/kotlin/pull/4280
Sounds reasonable to me. Also we might want to bring in all the other defaults from Gradle as that the source of truth we should follow at this point. cc @restingbull @Bencodes
I'm against adding these to the toolchain -- we want to move away from specific plugin arguments being embedded in the core infrastructure.
KSP has shown that the plugin ecosystem is robust enough to foster an entire new ecosystem of plugins on top of the old one.
It would be better to move KAPT (and KSP) into an extendable subsystem, as we've previously discussed.
It would be better to move KAPT (and KSP) into an extendable subsystem, as we've previously discussed.
@restingbull I'm not aware of the discussion care to elaborate more?
@restingbull can you elaborate on the preferred direction? Would having something like cc_library.copts or java_library.javacopts be workable? Maybe something like kapt_copts/ksp_copts and passing them directly in the rules?