Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add KAPT arguments to define_kt_toolchain #858

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mohamadk
Copy link

@mohamadk mohamadk commented Nov 2, 2022

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",
)

@@ -36,6 +36,12 @@ KtJvmInfo = provider(
},
)

KaptInfo = provider(
fields = {
"correctErrorTypes": "correct Error Types https://kotlinlang.org/docs/kapt.html#non-existent-type-correction",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we follow snake case i.e correct_error_types here to stay consistent with rest of the args?

@restingbull restingbull self-assigned this Nov 4, 2022
@mohamadk mohamadk force-pushed the add_kapt_arguments_to_kt_toolchain branch 4 times, most recently from 43daefc to d2f4434 Compare May 8, 2023 13:04
@arunkumar9t2
Copy link
Contributor

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 JetBrains/kotlin#4280

@nkoroste
Copy link
Collaborator

nkoroste commented May 8, 2023

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

@@ -395,6 +396,7 @@ def _run_kt_builder_action(
args.add_all("--deps_artifacts", deps_artifacts, omit_if_empty = True)
args.add_all("--kotlin_friend_paths", associates.jars, map_each = _associate_utils.flatten_jars)
args.add("--instrument_coverage", ctx.coverage_instrumented())
args.add("--kapt_correct_error_types", toolchains.kt.kaptInfo[_KaptInfo].correct_error_types)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just pass all the options in here like we do for Kotlinc/Javac/Ksp, otherwise we'd end up having to create new proto entries for every single kapt option that we want to support.

@mohamadk mohamadk force-pushed the add_kapt_arguments_to_kt_toolchain branch 6 times, most recently from 2c28d70 to 01608ea Compare May 15, 2023 10:40
@mohamadk mohamadk force-pushed the add_kapt_arguments_to_kt_toolchain branch from 01608ea to 767c879 Compare May 15, 2023 11:42
@restingbull
Copy link
Collaborator

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.

@mohamadk
Copy link
Author

mohamadk commented May 16, 2023

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?

@pswaminathan
Copy link
Contributor

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants