Skip to content
Open
Changes from all commits
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
9 changes: 7 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.toolchains["@bazel_tools//tools/jdk:runtime_toolchain_type"].java_runtime.java_executable_runfiles_path,
Copy link
Collaborator

Choose a reason for hiding this comment

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

)

content = ctx.expand_location(content, [ctx.attr._ktlint_tool])
Expand All @@ -109,9 +110,10 @@ SRCS=${{SRCS[@]/#/$BUILD_DIR}}
)

files = [ctx.executable._ktlint_tool]
transitive_files = ctx.toolchains["@bazel_tools//tools/jdk:runtime_toolchain_type"].java_runtime.files
if editorconfig:
files.append(editorconfig)
runfiles = ctx.runfiles(files = files)
runfiles = ctx.runfiles(files = files, transitive_files = transitive_files)

return [
DefaultInfo(
Expand Down Expand Up @@ -141,6 +143,9 @@ ktlint_fix = rule(
cfg = "target",
),
},
toolchains = [
"@bazel_tools//tools/jdk:runtime_toolchain_type",
],
executable = True,
doc = "Lint Kotlin files and automatically fix them as needed",
)