Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions kotlin/internal/lint/ktlint_fix.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ fi
SRCS=({srcs})
SRCS=${{SRCS[@]/#/$BUILD_DIR}}

"$TOOL" {args} $SRCS
PATH=\"$(dirname "{binjava}"):$PATH\" "$TOOL" {args} $SRCS
""".format(
executable = ctx.executable._ktlint_tool.path,
args = " ".join(args),
srcs = " ".join([src.path for src in ctx.files.srcs]),
binjava = ctx.attr._java[java_common.JavaRuntimeInfo].java_executable_runfiles_path,
)

content = ctx.expand_location(content, [ctx.attr._ktlint_tool])
Expand All @@ -108,7 +109,7 @@ SRCS=${{SRCS[@]/#/$BUILD_DIR}}
is_executable = True,
)

files = [ctx.executable._ktlint_tool]
files = [ctx.executable._ktlint_tool] + ctx.files._java
if editorconfig:
files.append(editorconfig)
runfiles = ctx.runfiles(files = files)
Expand Down Expand Up @@ -140,6 +141,9 @@ ktlint_fix = rule(
executable = True,
cfg = "target",
),
"_java": attr.label(
default = "@bazel_tools//tools/jdk:current_java_runtime",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be pulled from the java runtime toolchain -- @bazel_tools//tools/jdk:runtime_toolchain_type, rather than an attribute.

This is to ensure that the binary will respect platform during compilation. With RBE, it's not unusual to build binaries for a target platform on an incompatible exec. e.g. it ain't always host. :)

Otherwise, looks good.

),
},
executable = True,
doc = "Lint Kotlin files and automatically fix them as needed",
Expand Down