fix running kotlin targets (at least under bzlmod?) #1130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was just integrating rules_kotlin into an existing bazel project and run into some issues getting a simple kotlin app up and running. I was seeing the error
I explored a little and saw that these two fields in the java toolchain differed and explained the problem (since exec is what's being used, but runfiles is what points to the actual file.)
Looking at the docs for these two fields (https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaRuntimeInfoApi.java#L60 ) it looks to me like exec is for use while running java as part of the action, whereas runfiles is for use when using
bazel run
(but this is all a bit new to me so I might be wrong / perhaps there's some nuance -- e.g. I can see in (what looks to me like) the core java stuff, there's all sorts of complex stuff going on when they set javabin . . . -- https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/bazel/java/bazel_java_binary.bzl#L203 )env details
[edit] forgot to mention, that I'm using this as a patch and
bazel run <kotlin app target>
is working fine now