Skip to content

Commit

Permalink
Made as many dependencies dev dependencies as can be
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaden Peterson committed Dec 6, 2024
1 parent 42748f0 commit 20610a7
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 41 deletions.
10 changes: 0 additions & 10 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
load(
"@rules_java//toolchains:default_java_toolchain.bzl",
"DEFAULT_TOOLCHAIN_CONFIGURATION",
Expand All @@ -13,12 +12,3 @@ default_java_toolchain(
source_version = "21",
target_version = "21",
)

buildifier(
name = "buildifier",
)

buildifier_test(
name = "buildifier_check",
mode = "check",
)
10 changes: 7 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module(name = "rules_twirl")

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1")

bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)

bazel_dep(name = "rules_java", version = "7.11.1")
bazel_dep(name = "rules_pkg", version = "1.0.1")

bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True)

bazel_dep(name = "rules_jvm_external", version = "6.4")
bazel_dep(name = "rules_scala_annex")

Expand All @@ -16,7 +20,7 @@ archive_override(
urls = ["https://github.com/lucidsoftware/rules_scala/archive/refs/tags/{}.zip".format(rules_scala_annex_version)],
)

bazel_dep(name = "stardoc", version = "0.7.1")
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True)

register_toolchains(
"//:repository_default_toolchain_21_definition",
Expand Down
10 changes: 10 additions & 0 deletions dev/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")

buildifier(
name = "buildifier",
)

buildifier_test(
name = "buildifier_check",
mode = "check",
)
29 changes: 29 additions & 0 deletions dev/stardoc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Borrowed from lucidsoftware/rules_scala

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
load("@stardoc//stardoc:stardoc.bzl", "stardoc")

bzl_files = ["//twirl:twirl.bzl"]

[
stardoc(
name = paths.replace_extension(file, "_doc").removeprefix("//twirl:").replace("/", "_"),
out = paths.replace_extension(file, ".md").removeprefix("//twirl:").replace("/", "_"),
input = file,
symbol_names = ["twirl_templates"],
deps = [
"//twirl:bzl_internal",
],
)
for file in bzl_files
]

pkg_tar(
name = "docs",
srcs = [
paths.replace_extension(file, ".md").removeprefix("//twirl:").replace("/", "_")
for file in bzl_files
],
mode = "0644",
)
4 changes: 2 additions & 2 deletions scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

if [ "$#" -eq 0 ] || [ "$1" != check ]; then
bazel run buildifier
bazel run //dev:buildifier
else
bazel run buildifier_check
bazel run //dev:buildifier_check
fi
6 changes: 3 additions & 3 deletions scripts/gen-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Regenerates stardoc for the rules
#
# Borrowed from higherkindness/rules_scala
# Borrowed from lucidsoftware/rules_scala
#
set -euxo pipefail

Expand All @@ -11,8 +11,8 @@ cd "$(dirname "$0")/.."
rm -fr docs/stardoc
mkdir -p docs/stardoc

bazel build twirl:docs
tar xf "$(bazel info bazel-bin)/twirl/docs.tar" -C docs/stardoc
bazel build //dev/stardoc:docs
tar xf "$(bazel info bazel-bin)/dev/stardoc/docs.tar" -C docs/stardoc
find docs/stardoc -size 0 -print0 | while read path; do
rm $path
done
25 changes: 2 additions & 23 deletions twirl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
# Borrowed from higherkindness/rules_scala
# Borrowed from lucidsoftware/rules_scala

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@stardoc//stardoc:stardoc.bzl", "stardoc")

[
stardoc(
name = paths.replace_extension(file, "_doc").replace("/", "_"),
out = paths.replace_extension(file, ".md").replace("/", "_"),
input = file,
symbol_names = ["twirl_templates"],
deps = [
"//twirl:bzl_internal",
],
)
for file in glob(["**/*.bzl"])
]

pkg_tar(
name = "docs",
srcs = [paths.replace_extension(file, ".md").replace("/", "_") for file in glob(["**/*.bzl"])],
mode = "0644",
)
exports_files(["twirl.bzl"])

bzl_library(
name = "bzl_internal",
Expand Down

0 comments on commit 20610a7

Please sign in to comment.