Skip to content

Commit

Permalink
Fix buildifier
Browse files Browse the repository at this point in the history
Which also involves upgrading rules_sass and rules_nodejs
  • Loading branch information
tmccombs committed Sep 16, 2023
1 parent d29797c commit d4769fb
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 152 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")

buildifier(name = "buildifier")
95 changes: 61 additions & 34 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# rules_jvm_external
RULES_JVM_EXTERNAL_TAG = "5.3"

http_archive(
name = "rules_jvm_external",
sha256 = "6cc8444b20307113a62b676846c29ff018402fd4c7097fcd6d0a0fd5f2e86429",
Expand All @@ -13,88 +14,107 @@ http_archive(
)

load(":workspace.bzl", "twirl_repositories")

twirl_repositories()

load("@twirl//:defs.bzl", twirl_pinned_maven_install = "pinned_maven_install")

twirl_pinned_maven_install()

load(":test_workspace.bzl", "twirl_test_repositories")

twirl_test_repositories()

load("@twirl_test//:defs.bzl", twirl_test_pinned_maven_install = "pinned_maven_install")

twirl_test_pinned_maven_install()

# Skylib
skylib_version = "1.0.2" # update this as needed
skylib_version = "1.4.2" # update this as needed

http_archive(
name = "bazel_skylib",
sha256 = "64ad2728ccdd2044216e4cec7815918b7bb3bb28c95b7e9d951f9d4eccb07625",
sha256 = "0fa67483ecf6a7c62b892b6f0d68aa4135586478077f0f97c4fbf39201648cf4",
strip_prefix = "bazel-skylib-{}".format(skylib_version),
type = "zip",
url = "https://github.com/bazelbuild/bazel-skylib/archive/{}.zip".format(skylib_version),
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

# rules_nodejs
# To use the JavaScript version of Sass, we need to first install nodejs
rules_nodejs_version = "1.7.0"
rules_nodejs_version = "5.3.0"

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "82030031436c265e7fc427b08d581eeb658d1feca23c73df6e633b0951e9f14f",
sha256 = "322b2ecebd564586f5ccdd645833d7a2ecae2db554886e4435c3d02bdf2ecdf4",
strip_prefix = "rules_nodejs-{}".format(rules_nodejs_version),
type = "zip",
url = "https://github.com/bazelbuild/rules_nodejs/archive/{}.zip".format(rules_nodejs_version),
)

load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")

build_bazel_rules_nodejs_dependencies()

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
node_repositories(package_json = [])

node_repositories()

# rules_sass
rules_sass_version = "1.26.2" # update this as needed
rules_sass_version = "1.67.0" # update this as needed

http_archive(
name = "io_bazel_rules_sass",
sha256 = "a31026741e4af6f1e5bcc9cce23db0549ecdea6270c8919da09110886102eb8e",
sha256 = "b29eb037568be386f7d4976fd160fefac98e0e26e3056e55f0d3eba2a0afb874",
strip_prefix = "rules_sass-{}".format(rules_sass_version),
type = "zip",
url = "https://github.com/bazelbuild/rules_sass/archive/{}.zip".format(rules_sass_version),
)
load("@io_bazel_rules_sass//:package.bzl", "rules_sass_dependencies")
rules_sass_dependencies()

load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")

sass_repositories()

# Skydoc
skydoc_version = "0.3.0" # update this as needed
skydoc_version = "0.3.0" # update this as needed

http_archive(
name = "io_bazel_skydoc",
sha256 = "8762a212cff5f81505a1632630edcfe9adce381479a50a03c968bd2fc217972d",
strip_prefix = "skydoc-{}".format(skydoc_version),
type = "zip",
url = "https://github.com/bazelbuild/skydoc/archive/{}.zip".format(skydoc_version),
)

load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")

skydoc_repositories()

# buildifier
buildtools_version = "4.2.2"

http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3",
strip_prefix = "buildtools-{}".format(buildtools_version),
url = "https://github.com/bazelbuild/buildtools/archive/refs/tags/{}.tar.gz".format(buildtools_version)
name = "com_github_bazelbuild_buildtools",
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3",
strip_prefix = "buildtools-{}".format(buildtools_version),
url = "https://github.com/bazelbuild/buildtools/archive/refs/tags/{}.tar.gz".format(buildtools_version),
)


# buildifier is written in Go and hence needs rules_go to be built.
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
http_archive(
name = "io_bazel_rules_go",
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
],
name = "io_bazel_rules_go",
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")

go_rules_dependencies()
Expand All @@ -103,37 +123,44 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")

go_register_toolchains(version = "1.20.3")


# Also for buildifier. Comes from
# https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md
protobuf_version = "3.19.4"

http_archive(
name = "com_google_protobuf",
sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568",
strip_prefix = "protobuf-{}".format(protobuf_version),
url = "https://github.com/protocolbuffers/protobuf/archive/v{}.tar.gz".format(protobuf_version),
name = "com_google_protobuf",
sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568",
strip_prefix = "protobuf-{}".format(protobuf_version),
url = "https://github.com/protocolbuffers/protobuf/archive/v{}.tar.gz".format(protobuf_version),
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# higherkindness/rules_scala (used for tests only)
# TODO: Move tests into their own worskpace s.t. we don't need their dependenices here
rules_scala_annex_version = "938ffdc24fb25a58220aa650948761073f1dd83b"

http_archive(
name = "rules_scala_annex",
sha256 = "ae0cfd560a5238248d5f4c9fcde352e5dfc87cba5efd0b97e4c88ea839fd51b5",
strip_prefix = "rules_scala-{}".format(rules_scala_annex_version),
type = "zip",
url = "https://github.com/lucidsoftware/rules_scala/archive/{}.zip".format(rules_scala_annex_version),
name = "rules_scala_annex",
sha256 = "ae0cfd560a5238248d5f4c9fcde352e5dfc87cba5efd0b97e4c88ea839fd51b5",
strip_prefix = "rules_scala-{}".format(rules_scala_annex_version),
type = "zip",
url = "https://github.com/lucidsoftware/rules_scala/archive/{}.zip".format(rules_scala_annex_version),
)

bind(
name = "default_scala",
actual = "@rules_scala_annex//src/main/scala:zinc_2_12_10",
name = "default_scala",
actual = "@rules_scala_annex//src/main/scala:zinc_2_12_10",
)

load("@rules_scala_annex//rules/scala:workspace.bzl", "scala_register_toolchains", "scala_repositories")

scala_repositories()

load("@annex//:defs.bzl", annex_pinned_maven_install = "pinned_maven_install")

annex_pinned_maven_install()

scala_register_toolchains()
8 changes: 4 additions & 4 deletions compiler-cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
java_binary(
name = "compiler-cli",
runtime_deps = ["@twirl//:com_lucidchart_twirl_compiler_cli"],
main_class = "rulestwirl.twirl.CommandLineTwirlTemplateCompiler",
visibility = ["//visibility:public"]
name = "compiler-cli",
main_class = "rulestwirl.twirl.CommandLineTwirlTemplateCompiler",
visibility = ["//visibility:public"],
runtime_deps = ["@twirl//:com_lucidchart_twirl_compiler_cli"],
)
82 changes: 41 additions & 41 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@ load("@rules_scala_annex//rules:scala.bzl", "scala_test")
load("//twirl:twirl.bzl", "twirl_templates")

twirl_templates(
name = "twirl-test-templates-basic",
visibility = ["//visibility:public"],
source_directory = "twirl-templates",
srcs = [
"twirl-templates/twirl/com/foo/views/hello.scala.html",
"twirl-templates/twirl/com/foo/views/hello.scala.txt",
"twirl-templates/twirl/com/foo/views/hello.scala.xml",
"twirl-templates/twirl/com/foo/views/hello.scala.js",
],
name = "twirl-test-templates-basic",
srcs = [
"twirl-templates/twirl/com/foo/views/hello.scala.html",
"twirl-templates/twirl/com/foo/views/hello.scala.js",
"twirl-templates/twirl/com/foo/views/hello.scala.txt",
"twirl-templates/twirl/com/foo/views/hello.scala.xml",
],
source_directory = "twirl-templates",
visibility = ["//visibility:public"],
)

twirl_templates(
name = "twirl-test-templates-additional-imports",
visibility = ["//visibility:public"],
source_directory = "twirl-templates",
srcs = [
"twirl-templates/twirl/com/foo/views/addImports.scala.txt",
],
additional_imports = ["rulestwirl.test.Person"],
name = "twirl-test-templates-additional-imports",
srcs = [
"twirl-templates/twirl/com/foo/views/addImports.scala.txt",
],
additional_imports = ["rulestwirl.test.Person"],
source_directory = "twirl-templates",
visibility = ["//visibility:public"],
)

twirl_templates(
name = "twirl-test-templates-custom-formatter",
visibility = ["//visibility:public"],
source_directory = "twirl-templates",
srcs = [
"twirl-templates/twirl/com/foo/views/customFormatter.scala.txt",
],
additional_imports = ["rulestwirl.test.Person"],
template_formats = {
"txt": "rulestwirl.test.StrangeTxtFormat"
},
name = "twirl-test-templates-custom-formatter",
srcs = [
"twirl-templates/twirl/com/foo/views/customFormatter.scala.txt",
],
additional_imports = ["rulestwirl.test.Person"],
source_directory = "twirl-templates",
template_formats = {
"txt": "rulestwirl.test.StrangeTxtFormat",
},
visibility = ["//visibility:public"],
)

scala_test(
name = "twirl-compiler-test",
srcs = [
"TwirlCompilerTest.scala",
"Person.scala",
"StrangeTxtFormatter.scala",
":twirl-test-templates-basic",
":twirl-test-templates-additional-imports",
":twirl-test-templates-custom-formatter",
],
deps = [
"@twirl_test//:com_typesafe_play_twirl_api_2_12",
"@twirl_test//:org_specs2_specs2_common_2_12",
"@twirl_test//:org_specs2_specs2_core_2_12",
"@twirl_test//:org_specs2_specs2_matcher_2_12",
],
name = "twirl-compiler-test",
srcs = [
"Person.scala",
"StrangeTxtFormatter.scala",
"TwirlCompilerTest.scala",
":twirl-test-templates-additional-imports",
":twirl-test-templates-basic",
":twirl-test-templates-custom-formatter",
],
deps = [
"@twirl_test//:com_typesafe_play_twirl_api_2_12",
"@twirl_test//:org_specs2_specs2_common_2_12",
"@twirl_test//:org_specs2_specs2_core_2_12",
"@twirl_test//:org_specs2_specs2_matcher_2_12",
],
)
Loading

0 comments on commit d4769fb

Please sign in to comment.