Skip to content

Commit

Permalink
!fixup PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjudd committed Sep 25, 2024
1 parent 61888f0 commit 3625a94
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 35 deletions.
9 changes: 8 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ startup --expand_configs_in_place

common:ci --color=yes

common --experimental_output_paths=off

build --strategy=worker,sandboxed,local
build --verbose_failures

build --sandbox_debug
build --incompatible_strict_action_env
build --experimental_worker_multiplex_sandboxing
build --experimental_worker_cancellation
build --worker_sandboxing

build --java_language_version="21"
build --java_runtime_version="remotejdk_21"
build --tool_java_language_version="21"
build --tool_java_runtime_version="remotejdk_21"

build:ci --verbose_failures
build:ci --sandbox_debug
build:ci --spawn_strategy=standalone
build:ci --genrule_strategy=standalone
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ rules_jvm_external_deps()
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
rules_jvm_external_setup()

load(
"//:workspace.bzl",
"play_routes_compiler_cli_2_13_repositories",
"play_routes_compiler_cli_3_repositories",
)
play_routes_compiler_cli_3_repositories()
load("@play_routes_compiler_cli_3//:defs.bzl", play_routes_compiler_cli_3_pinned_maven_install = "pinned_maven_install")
play_routes_compiler_cli_3_pinned_maven_install()
Expand Down
8 changes: 5 additions & 3 deletions play-routes-compiler-cli/CommandLinePlayRoutesCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import higherkindness.rules_scala.common.error.AnnexWorkerError
import higherkindness.rules_scala.common.worker.WorkerMain
import higherkindness.rules_scala.common.sandbox.SandboxUtil
import java.io.{File, PrintStream}
import java.lang.Class
import java.nio.file.{Files, Path, Paths}
import play.routes.compiler._
import play.routes.compiler.RoutesCompiler.RoutesCompilerTask
Expand Down Expand Up @@ -38,7 +39,7 @@ object CommandLinePlayRoutesCompiler extends WorkerMain[Unit] {
arg[Path]("<outputDirectory>").required().action { (outputDirectory, config) =>
config.outputDirectory = SandboxUtil.getSandboxPath(workDir, outputDirectory)
config
}.text("directory to output compiled routes to")
}.text("directory to output compiled routes to before packaging them in a JAR")

arg[Path]("<outputSrcJar>").required().action { (outputSrcJar, config) =>
config.outputSrcJar = SandboxUtil.getSandboxPath(workDir, outputSrcJar)
Expand All @@ -63,10 +64,11 @@ object CommandLinePlayRoutesCompiler extends WorkerMain[Unit] {
} else {
routesGeneratorClassString + "$"
}
val clazz = java.lang.Class.forName(name, true, getClass.getClassLoader)
val clazz = Class.forName(name)
// val clazz = java.lang.Class.forName(name, true, getClass.getClassLoader)
clazz.getField("MODULE$").get(null).asInstanceOf[RoutesGenerator]
} catch {
case e: Exception => {
case e @ (_:Exception | _:LinkageError | _:ExceptionInInitializerError) => {
throw new Exception(
s"Could not instantiate a routes generator from the given class: ${routesGeneratorClassString}",
e,
Expand Down
4 changes: 1 addition & 3 deletions play-routes-toolchain/transitions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ def _play_routes_toolchain_transition_impl(settings, attr):
"""Update the rules_play_routes toolchain to the overridden value. Store
The original value, so it can be reset on the outgoing transition.
"""
if attr.play_routes_toolchain_name == "":
return {}
elif settings[toolchain_setting_key] == attr.play_routes_toolchain_name:
if attr.play_routes_toolchain_name == "" or attr.play_routes_toolchain_name == settings[toolchain_setting_key]:
# Do nothing when the attribute value is what the setting currently is
# otherwise needlessly change build settings by modifying the setting
# we store the original value in
Expand Down
4 changes: 4 additions & 0 deletions play-routes/play-routes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def _impl(ctx):
),
]

# If you add any labels or label_lists, you will need to add the
# reset_play_routes_toolchain_transition outgoing transition to it. Otherwise
# you'll end up needlessly changing build config and causing an explosion in
# size for the build graph.
play_routes = rule(
implementation = _impl,
doc = "Compiles Play routes files templates to Scala sources files.",
Expand Down
39 changes: 13 additions & 26 deletions test_workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,28 @@ play_version = "3.0.4"
specs2_version = "4.20.8"

def play_routes_test_3_repositories():
maven_install(
name = "play_routes_test_3",
artifacts = [
"org.specs2:specs2-common_3:{}".format(specs2_version),
"org.specs2:specs2-core_3:{}".format(specs2_version),
"org.specs2:specs2-matcher_3:{}".format(specs2_version),
"org.playframework:play_3:{}".format(play_version),
"org.playframework:play-test_3:{}".format(play_version),
"org.playframework:play-specs2_3:{}".format(play_version),
],
repositories = [
"https://repo.maven.apache.org/maven2",
"https://maven-central.storage-download.googleapis.com/maven2",
"https://mirror.bazel.build/repo1.maven.org/maven2",
],
fetch_sources = True,
maven_install_json = "@rules_play_routes//:play_routes_test_3_install.json",
)
play_routes_test_repositories(scala_version = "3")

def play_routes_test_2_13_repositories():
play_routes_test_repositories(scala_version = "2.13")

def play_routes_test_repositories(scala_version):
scala_version_underscore = scala_version.replace(".", "_")
maven_install(
name = "play_routes_test_2_13",
name = "play_routes_test_{}".format(scala_version_underscore),
artifacts = [
"org.specs2:specs2-common_2.13:{}".format(specs2_version),
"org.specs2:specs2-core_2.13:{}".format(specs2_version),
"org.specs2:specs2-matcher_2.13:{}".format(specs2_version),
"org.playframework:play_2.13:{}".format(play_version),
"org.playframework:play-test_2.13:{}".format(play_version),
"org.playframework:play-specs2_2.13:{}".format(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),
"org.playframework:play_{}:{}".format(scala_version, play_version),
"org.playframework:play-test_{}:{}".format(scala_version, play_version),
"org.playframework:play-specs2_{}:{}".format(scala_version, play_version),
],
repositories = [
"https://repo.maven.apache.org/maven2",
"https://maven-central.storage-download.googleapis.com/maven2",
"https://mirror.bazel.build/repo1.maven.org/maven2",
],
fetch_sources = True,
maven_install_json = "@rules_play_routes//:play_routes_test_2_13_install.json",
maven_install_json = "@rules_play_routes//:play_routes_test_{}_install.json".format(scala_version_underscore),
)
5 changes: 3 additions & 2 deletions workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ load("//scala:version.bzl", "scala_2_13_version", "scala_3_version")
play_version = "3.0.4"
zinc_version = "1.10.1"
protobuf_version = "3.19.4"
scopt_version = "4.1.0"

def play_routes_compiler_cli_3_repositories():
maven_install(
name = "play_routes_compiler_cli_3",
artifacts = [
"com.github.scopt:scopt_3:4.1.0",
"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),
Expand All @@ -36,7 +37,7 @@ def play_routes_compiler_cli_2_13_repositories():
maven_install(
name = "play_routes_compiler_cli_2_13",
artifacts = [
"com.github.scopt:scopt_2.13:4.1.0",
"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),
Expand Down

0 comments on commit 3625a94

Please sign in to comment.