Skip to content

Bazel rules for compiling Play Framework routes files

License

Notifications You must be signed in to change notification settings

kojustin/rules_play_routes

 
 

Repository files navigation

Play Framework Routes File Rules for Bazel

Travis Stardoc
Build Status Stardoc

Overview

rules_play_routes compiles Play Framework routes files templates to Scala, so they can be used with rules_scala.

For more information about the Play Framework, see the Play documentation.

Installation

Create a file called at the top of your repository named WORKSPACE and add the following snippet to it.

# update version as needed
rules_play_routes_version = "beca1e224c9f08813b55498da6db7f91721edea7"
http_archive(
  name = "io_bazel_rules_play_routes",
  sha256 = "bb37e52bf5bf2d11732b07e3baa1508b0cfdb9f8ce7645f346e215a954380a41",
  strip_prefix = "rules_play_routes-{}".format(rules_play_routes_version),
  type = "zip",
  url = "https://github.com/lucidsoftware/rules_play_routes/archive/{}.zip".format(rules_play_routes_version),
)

load("@rules_play_routes//play-routes:play-routes.bzl", "play_repositories")

play_repositories()

This installs rules_play_routes to your WORKSPACE at the specified commit. Update the commit as needed.

Stardoc Documentation

http://lucidsoftware.github.io/rules_play_routes/

Stardoc is replacing Skydoc and is currently under development. Doc is likely going to look funny for a while.

Updating Stardoc

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.

Deploying documentation

The Stardoc site for rules_play_routes is deployed from the gh-pages branch. That branch is deployed with each build of the master branch.

Usage

The play_routes rule compiles Play routes files to a source jar that can be used with the rules_scala rules. For example,

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"]) + [":play-routes"],
  main_class = "foo.server.RunServer",
  deps = [...]
  )
)

See the Stardoc documentation for the full list of options for play_routes.

Use with the Play Framework

play_routes can be used with rules_twirl 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 = [...],
)

Development

Command Line Play Routes Compiler

This project consists of the Play routes Bazel rules and a command line Play routes compiler compiler. The command line compiler can be built with

bazel build //play-routes-compiler

It can be run with

bazel run //play-routes-compiler

Testing

All tests can be run using

test/run_all_tests.sh

They can also be run using

bazel test //test/...

CI

The CI config in tools/bazel.rc and other options in .bazelrc.travis are used during CI builds.

Skylint

Skylint is run during CI builds. To run it locally use

tools/skylint.sh

About

Bazel rules for compiling Play Framework routes files

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 63.2%
  • Scala 29.5%
  • Shell 7.3%