Travis | Doc |
---|---|
Stardoc |
rules_twirl
compiles Twirl templates to Scala, so they can be used with rules_scala
.
For more information about Twirl templates, see the Play Twirl documentation.
Create a file called at the top of your repository named WORKSPACE
and add the following snippet to it.
# update version as needed
rules_twirl_version = "ae15eba1647917daf1cf6cff160112cbc72ecc9d"
http_archive(
name = "io_bazel_rules_twirl",
sha256 = "5ac0c813f23d616ab78e1fda209253310d30458f7b30451010a9984876de2bbc",
url = "https://github.com/lucidsoftware/rules_twirl/archive/%s.zip"%rules_twirl_version,
type = "zip",
strip_prefix= "rules_twirl-%s" % rules_twirl_version
)
This installs rules_twirl
to your WORKSPACE
at the specified commit. Update the commit as needed.
http://lucidsoftware.github.io/rules_twirl/
Stardoc is replacing Skydoc and is currently under development. Doc is likely going to look funny for a while.
Stardoc is automatically updated on build merged into the master branch. To update the documentation, please submit a pull request. The doc will be updated when it is merged.
The Stardoc site for rules_twirl
is deployed from the gh-pages
branch. That branch is deployed with each build of the master branch.
The twirl_templates
rule compiles Twirl templates to a source jar that can be used with the rules_scala
rules. For example,
twirl_templates(
name = "twirl-templates",
source_directory = "app",
srcs = glob(["app/**/*.scala.html"])
+ glob(["app/**/*.scala.xml"])
+ glob(["app/**/*.scala.js"])
+ glob(["app/**/*.scala.txt"]),
)
scala_binary(
name = "foo-service",
srcs = glob(["app/**/*.scala"]) + [":twirl-templates"],
main_class = "foo.server.RunServer",
deps = [...]
)
)
See the Stardoc documentation for the full list of options for twirl_templates
.
twirl_templates
can be used with the rules_play_routes
to run a Play Framework Service. For example
twirl_templates(
name = "twirl-templates",
source_directory = "app",
include_play_imports = True,
srcs = glob(["app/**/*.scala.html"])
+ glob(["app/**/*.scala.xml"])
+ glob(["app/**/*.scala.js"])
+ glob(["app/**/*.scala.txt"]),
additional_imports = [...],
)
play_routes(
name = "play-routes",
srcs = ["conf/routes"] + glob(["conf/*.routes"]),
include_play_imports = True,
generate_reverse_router = True,
routes_imports = [...],
)
scala_binary(
name = "foo-service",
srcs = glob(["app/**/*.scala"]) + [":twirl-templates", ":play-routes"],
visibility = ["//visibility:public"],
main_class = "play.core.server.ProdServerStart",
resources = ["conf/logback.xml"] + glob(["conf/resources/**/*"]),
resource_strip_prefix = native.package_name(),
classpath_resources = ["conf/application.conf"],
jvm_flags = [
"-Dhttp.port=9000",
"-Dapplication.name=foo-service",
],
deps = [...],
)
This project consists of the Twirl Bazel rules and a command line Twirl compiler. The command line compiler can be built with
bazel build //twirl-compiler
It can be run with
bazel run //twirl-compiler
All tests can be run using
test/run_all_tests.sh
They can also be run using
bazel test //test/...
The CI config in tools/bazel.rc
and other options in .bazelrc.travis
are used during CI builds.
Skylint is run during CI builds. To run it locally use
tools/skylint.sh