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

Switch to a prebuilt buildifier #1285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
29 changes: 5 additions & 24 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -121,32 +121,13 @@ http_file(
urls = [COURSIER_CLI_GITHUB_ASSET_URL],
)

http_file(
name = "buildifier-linux-arm64",
sha256 = "c22a44eee37b8927167ee6ee67573303f4e31171e7ec3a8ea021a6a660040437",
urls = ["https://github.com/bazelbuild/buildtools/releases/download/v7.1.2/buildifier-linux-arm64"],
)

http_file(
name = "buildifier-linux-x86_64",
sha256 = "28285fe7e39ed23dc1a3a525dfcdccbc96c0034ff1d4277905d2672a71b38f13",
urls = ["https://github.com/bazelbuild/buildtools/releases/download/v7.1.2/buildifier-linux-amd64"],
)

http_file(
name = "buildifier-macos-arm64",
sha256 = "d0909b645496608fd6dfc67f95d9d3b01d90736d7b8c8ec41e802cb0b7ceae7c",
urls = ["https://github.com/bazelbuild/buildtools/releases/download/v7.1.2/buildifier-darwin-arm64"],
)

http_file(
name = "buildifier-macos-x86_64",
sha256 = "687c49c318fb655970cf716eed3c7bfc9caeea4f2931a2fd36593c458de0c537",
urls = ["https://github.com/bazelbuild/buildtools/releases/download/v7.1.2/buildifier-darwin-amd64"],
)

############# Dev dependencies below here

bazel_dep(
name = "buildifier_prebuilt",
version = "7.3.1",
dev_dependency = True,
)
bazel_dep(
name = "protobuf",
# Note: we use 27.2 in MODULE.bazel to avoid the warning:
Expand Down
18 changes: 2 additions & 16 deletions scripts/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ load("@rules_java//java:defs.bzl", "java_binary")
load("//private:versions.bzl", "COURSIER_CLI_HTTP_FILE_NAME")
load("//private/rules:artifact.bzl", "artifact")

genrule(
name = "buildifier-bin",
srcs = select({
"@bazel_tools//src/conditions:darwin_arm64": ["@buildifier-macos-arm64//file"],
"@bazel_tools//src/conditions:darwin_x86_64": ["@buildifier-macos-x86_64//file"],
"@bazel_tools//src/conditions:linux_aarch64": ["@buildifier-linux-arm64//file"],
"@bazel_tools//src/conditions:linux_x86_64": ["@buildifier-linux-x86_64//file"],
}),
outs = ["buildifier"],
cmd = "cp $< $@",
)

sh_binary(
name = "mirror_coursier",
srcs = [":mirror_coursier.sh"],
Expand Down Expand Up @@ -66,13 +54,13 @@ set -eufo pipefail

cwd="\\$${BUILD_WORKSPACE_DIRECTORY:=\\$$(pwd)}"
javaformat="\\$$1"
buildifier="\\$$2"

# Format java code
find "\\$$cwd" -type f -name "*.java" | xargs "\\$${javaformat}" --replace

# Run buildifier
\\$${buildifier} --lint fix --mode fix -r "\\$$cwd"
cd \\$$cwd
bazel run @buildifier_prebuilt//buildifier -- --lint fix --mode fix -r "\\$$cwd"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does using buildifier as a data dep not work? bazel running bazel run is a little odd.


EOL
""",
Expand All @@ -84,10 +72,8 @@ sh_binary(
srcs = [":format-script"],
args = [
"$(location :google-java-format)",
"$(location :buildifier)",
],
data = [
":buildifier",
":google-java-format",
],
)
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/maven_bom/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_java//java:defs.bzl", "java_library")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("//:defs.bzl", "artifact", "java_export", "maven_bom")

maven_bom(
Expand Down
1 change: 0 additions & 1 deletion tests/unit/exports/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_java//java:defs.bzl", "java_library")
load("//tests/unit/exports:exports_test.bzl", "exports_tests")

exports_tests(name = "exports_tests")