Skip to content

Commit

Permalink
Merge pull request #47 from lucidsoftware/bzlmod-migration
Browse files Browse the repository at this point in the history
Migrate to Bzlmod
  • Loading branch information
jadenPete authored Dec 6, 2024
2 parents 5621aa4 + 20610a7 commit 359a052
Show file tree
Hide file tree
Showing 23 changed files with 1,198 additions and 800 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
startup --expand_configs_in_place

common --@rules_scala_annex//rules/scala:scala-toolchain=zinc_3
common:ci --color=yes

build --strategy=worker,sandboxed,local
Expand Down
10 changes: 0 additions & 10 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@com_github_bazelbuild_buildtools//buildifier:def.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",
)
147 changes: 141 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,141 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
module(name = "rules_twirl")

bazel_dep(name = "bazel_skylib", version = "1.7.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", dev_dependency = True)

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

rules_scala_annex_version = "lucid_2024-12-06"

archive_override(
module_name = "rules_scala_annex",
integrity = "sha256-lSbyWlYtgP0ENngg4gKU1EBJ8d1sgMQKJlmOHwmCw3k=",
strip_prefix = "rules_scala-{}".format(rules_scala_annex_version),
urls = ["https://github.com/lucidsoftware/rules_scala/archive/refs/tags/{}.zip".format(rules_scala_annex_version)],
)

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

register_toolchains(
"//:repository_default_toolchain_21_definition",
"//scala:zinc_2_13",
"//scala:zinc_3",
"//twirl-toolchain:twirl-2-13",
"//twirl-toolchain:twirl-3",
)

# Please ensure these stay up-to-date with the versions in `versions.bzl`. Unfortunately,
# `MODULE.bazel` files can't call `load`, so we have to copy them here.
scala_2_13_version = "2.13.14"

scala_3_version = "3.5.1"

twirl_version = "2.0.7"

protobuf_version = "4.28.3"

scopt_version = "4.1.0"

specs2_version = "4.20.8"

zinc_version = "1.10.4"

twirl_compiler_cli_2_13 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
twirl_compiler_cli_2_13.install(
name = "twirl_compiler_cli_2_13",
artifacts = [
"com.github.scopt:scopt_2.13:{}".format(scopt_version),
"com.google.protobuf:protobuf-java:{}".format(protobuf_version),
"org.playframework.twirl:twirl-compiler_2.13:{}".format(twirl_version),
"org.scala-lang:scala-compiler:{}".format(scala_2_13_version),
"org.scala-lang:scala-library:{}".format(scala_2_13_version),
"org.scala-lang:scala-reflect:{}".format(scala_2_13_version),
"org.scala-sbt:compiler-interface:{}".format(zinc_version),
"org.scala-sbt:util-interface:{}".format(zinc_version),
"org.scala-sbt:zinc_2.13:{}".format(zinc_version),
],
fail_if_repin_required = True,
fetch_sources = True,
lock_file = "@rules_twirl//:twirl_compiler_cli_2_13_install.json",
repositories = ["https://repo.maven.apache.org/maven2"],
)

# Set neverlink = True to avoid Scala 2 library being pulled on to the wrong compiler classpath
twirl_compiler_cli_2_13.artifact(
name = "twirl_compiler_cli_2_13",
artifact = "compiler-bridge_2.13",
group = "org.scala-sbt",
neverlink = True,
version = zinc_version,
)
use_repo(twirl_compiler_cli_2_13, "twirl_compiler_cli_2_13")

twirl_compiler_cli_3 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
twirl_compiler_cli_3.install(
name = "twirl_compiler_cli_3",
artifacts = [
"com.github.scopt:scopt_3:{}".format(scopt_version),
"com.google.protobuf:protobuf-java:{}".format(protobuf_version),
"org.playframework.twirl:twirl-compiler_3:{}".format(twirl_version),
"org.scala-lang:scala3-compiler_3:{}".format(scala_3_version),
"org.scala-lang:scala3-library_3:{}".format(scala_3_version),
"org.scala-sbt:compiler-interface:{}".format(zinc_version),
"org.scala-sbt:util-interface:{}".format(zinc_version),
"org.scala-sbt:zinc_2.13:{}".format(zinc_version),
],
fail_if_repin_required = True,
fetch_sources = True,
lock_file = "@rules_twirl//:twirl_compiler_cli_3_install.json",
repositories = ["https://repo.maven.apache.org/maven2"],
)

# Set neverlink = True to avoid Scala 2 library being pulled on to the compiler classpath
twirl_compiler_cli_3.artifact(
name = "twirl_compiler_cli_3",
artifact = "scala3-sbt-bridge",
group = "org.scala-lang",
neverlink = True,
version = scala_3_version,
)
use_repo(twirl_compiler_cli_3, "twirl_compiler_cli_3")

twirl_test_2_13_artifacts, twirl_test_3_artifacts = [
[
"org.playframework.twirl:twirl-api_{}:{}".format(scala_version, twirl_version),
"org.specs2:specs2-common_{}:{}".format(scala_version, specs2_version),
"org.specs2:specs2-core_{}:{}".format(scala_version, specs2_version),
"org.specs2:specs2-matcher_{}:{}".format(scala_version, specs2_version),
]
for scala_version in [
"2.13",
"3",
]
]

twirl_test_2_13 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
twirl_test_2_13.install(
name = "twirl_test_2_13",
artifacts = twirl_test_2_13_artifacts,
fail_if_repin_required = True,
fetch_sources = True,
lock_file = "@rules_twirl//:twirl_test_2_13_install.json",
repositories = ["https://repo.maven.apache.org/maven2"],
)
use_repo(twirl_test_2_13, "twirl_test_2_13")

twirl_test_3 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
twirl_test_3.install(
name = "twirl_test_3",
artifacts = twirl_test_3_artifacts,
fail_if_repin_required = True,
fetch_sources = True,
lock_file = "@rules_twirl//:twirl_test_3_install.json",
repositories = ["https://repo.maven.apache.org/maven2"],
)
use_repo(twirl_test_3, "twirl_test_3")
Loading

0 comments on commit 359a052

Please sign in to comment.