Skip to content

Commit

Permalink
Merge pull request #57 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 5c012e7 + 7edf46f commit 615c4bc
Show file tree
Hide file tree
Showing 23 changed files with 959 additions and 2,072 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")
load(
"@rules_java//toolchains:default_java_toolchain.bzl",
"DEFAULT_JAVACOPTS",
Expand All @@ -16,12 +15,3 @@ default_java_toolchain(
source_version = "21",
target_version = "21",
)

buildifier(
name = "buildifier",
)

buildifier(
name = "buildifier_check",
mode = "check",
)
157 changes: 151 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,151 @@
###############################################################################
# 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_play_routes")

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_jvm_external", version = "6.4")

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

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",
"//play-routes-toolchain:play-routes-3",
"//play-routes-toolchain:play-routes-2-13",
"//scala:zinc_2_13",
"//scala:zinc_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.
play_version = "3.0.4"

# Please ensure these stay up-to-date with the versions in `scala/version.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"

protobuf_version = "4.28.3"

scopt_version = "4.1.0"

specs2_version = "4.20.8"

zinc_version = "1.10.4"

play_routes_compiler_cli_2_13 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
play_routes_compiler_cli_2_13.install(
name = "play_routes_compiler_cli_2_13",
artifacts = [
"com.github.scopt:scopt_2.13:{}".format(scopt_version),
"com.google.protobuf:protobuf-java:{}".format(protobuf_version),
"org.playframework:play-routes-compiler_2.13:{}".format(play_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 = "//:play_routes_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
play_routes_compiler_cli_2_13.artifact(
name = "play_routes_compiler_cli_2_13",
artifact = "compiler-bridge_2.13",
group = "org.scala-sbt",
neverlink = True,
version = zinc_version,
)
use_repo(play_routes_compiler_cli_2_13, "play_routes_compiler_cli_2_13")

play_routes_compiler_cli_3 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
play_routes_compiler_cli_3.install(
name = "play_routes_compiler_cli_3",
artifacts = [
"com.github.scopt:scopt_3:{}".format(scopt_version),
"com.google.protobuf:protobuf-java:{}".format(protobuf_version),
"org.playframework:play-routes-compiler_3:{}".format(play_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:zinc_2.13:{}".format(zinc_version),
"org.scala-sbt:util-interface:{}".format(zinc_version),
],
fail_if_repin_required = True,
fetch_sources = True,
lock_file = "@rules_play_routes//:play_routes_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
play_routes_compiler_cli_3.artifact(
name = "play_routes_compiler_cli_3",
artifact = "scala3-sbt-bridge",
group = "org.scala-lang",
neverlink = True,
version = scala_3_version,
)
use_repo(play_routes_compiler_cli_3, "play_routes_compiler_cli_3")

play_routes_test_2_13_artifacts, play_routes_test_3_artifacts = [
[
"org.playframework:play_{}:{}".format(scala_version, play_version),
"org.playframework:play-specs2_{}:{}".format(scala_version, play_version),
"org.playframework:play-test_{}:{}".format(scala_version, play_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",
]
]

play_routes_test_repositories = [
"https://maven-central.storage-download.googleapis.com/maven2",
"https://mirror.bazel.build/repo1.maven.org/maven2",
"https://repo.maven.apache.org/maven2",
]

play_routes_test_2_13 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
play_routes_test_2_13.install(
name = "play_routes_test_2_13",
artifacts = play_routes_test_2_13_artifacts,
fail_if_repin_required = True,
fetch_sources = True,
lock_file = "@rules_play_routes//:play_routes_test_2_13_install.json",
repositories = play_routes_test_repositories,
)
use_repo(play_routes_test_2_13, "play_routes_test_2_13")

play_routes_test_3 = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
play_routes_test_3.install(
name = "play_routes_test_3",
artifacts = play_routes_test_3_artifacts,
fail_if_repin_required = True,
fetch_sources = True,
lock_file = "@rules_play_routes//:play_routes_test_3_install.json",
repositories = play_routes_test_repositories,
)
use_repo(play_routes_test_3, "play_routes_test_3")
Loading

0 comments on commit 615c4bc

Please sign in to comment.