lucidsoftware / rules_twirl

Bazel rules for compiling Twirl templates
Apache License 2.0
3 stars 9 forks source link

not found: object play #38

Open mglee72 opened 3 years ago

mglee72 commented 3 years ago

My Workspace (identical to the README):

# update version as needed
rules_twirl_version = "9ac789845e3a481fe520af57bd47a4261edb684f"
http_archive(
  name = "io_bazel_rules_twirl",
  sha256 = "b1698a2a59b76dc9df233314c2a1ca8cee4a0477665cff5eafd36f92057b2044",
  strip_prefix = "rules_twirl-{}".format(rules_twirl_version),
  type = "zip",
  url = "https://github.com/lucidsoftware/rules_twirl/archive/{}.zip".format(rules_twirl_version),
)

RULES_JVM_EXTERNAL_TAG = "3.3"
http_archive(
    name = "rules_jvm_external",
    sha256 = "d85951a92c0908c80bd8551002d66cb23c3434409c814179c0ff026b53544dab",
    strip_prefix = "rules_jvm_external-{}".format(RULES_JVM_EXTERNAL_TAG),
    type = "zip",
    url = "https://github.com/bazelbuild/rules_jvm_external/archive/{}.zip".format(RULES_JVM_EXTERNAL_TAG),
)

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

My BUILD:

load("@io_bazel_rules_twirl//twirl:twirl.bzl", "twirl_templates")

twirl_templates(
  name = "twirl-templates",
  source_directory = "templates",
  include_play_imports = True,
  srcs = glob(["templates/**/*.scala.html"])
    + glob(["templates/**/*.scala.xml"])
    + glob(["templates/**/*.scala.js"])
    + glob(["templates/**/*.scala.txt"]),
)

scala_binary(
  name = "test-main",
  srcs = glob(["Main.scala"]) + [":twirl-templates"],
  main_class = "com.foo.bar.Main",
  deps = []
)

My HTML named templates/foo.scala.html (no arg):

<html>
  <body>
    <p>Hello World</p>
  </body>
</html>>

And I'm getting

/templates/foo.html.scala:4: error: not found: object play
import play.twirl.api._

and similar issues with resolving play. I don't have play embedded in our bazel, I'm mostly trying to use twirl as a stand alone codegen. Is there a step I'm missing?