{"id":34524487,"url":"https://github.com/lucidsoftware/rules_play_routes","last_synced_at":"2025-12-24T05:04:32.167Z","repository":{"id":28062264,"uuid":"116088104","full_name":"lucidsoftware/rules_play_routes","owner":"lucidsoftware","description":"Bazel rules for compiling Play Framework routes files","archived":false,"fork":false,"pushed_at":"2025-04-18T00:50:21.000Z","size":500,"stargazers_count":11,"open_issues_count":2,"forks_count":13,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-18T14:29:54.008Z","etag":null,"topics":["bazel","play-framework","scala"],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucidsoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-01-03T03:43:16.000Z","updated_at":"2025-03-25T18:04:51.000Z","dependencies_parsed_at":"2024-11-15T06:17:27.750Z","dependency_job_id":"e64b89f5-620b-4e01-a397-b0a7efb89ef2","html_url":"https://github.com/lucidsoftware/rules_play_routes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lucidsoftware/rules_play_routes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidsoftware%2Frules_play_routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidsoftware%2Frules_play_routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidsoftware%2Frules_play_routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidsoftware%2Frules_play_routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidsoftware","download_url":"https://codeload.github.com/lucidsoftware/rules_play_routes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidsoftware%2Frules_play_routes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27995843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","play-framework","scala"],"created_at":"2025-12-24T05:03:50.623Z","updated_at":"2025-12-24T05:04:32.153Z","avatar_url":"https://github.com/lucidsoftware.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Play Framework Routes File Rules for Bazel\n\n| Status | Stardoc\n| --- | --- |\n| [![Build Status](https://github.com/lucidsoftware/rules_play_routes/workflows/CI/badge.svg)](https://github.com/lucidsoftware/rules_play_routes/actions) | [Stardoc](docs/stardoc/play-routes.md) |\n\n## Overview\n`rules_play_routes` compiles\n[Play Framework routes files](https://www.playframework.com/documentation/latest/ScalaRouting)\ntemplates to [Scala](http://www.scala-lang.org/), so they can be used with\n[`bazelbuild/rules_scala`](https://github.com/bazelbuild/rules_scala) and\n[`lucidsoftware/rules_scala`](https://github.com/lucidsoftware/rules_scala).\n\nSimple Core API: [play_routes](docs/stardoc/play-routes.md)\n\nFor more information about the Play Framework, see\n[the Play documentation](https://www.playframework.com/documentation/latest).\n\n## Installation\n\n`rules_play_routes` isn't yet on the [Bazel Central Registry](https://registry.bazel.build/), so\nyou'll need to pull it in via `archive_override`. Be sure to replace `\u003cCOMMIT\u003e` with the\nlatest commit on `master` and `\u003cINTEGRITY\u003e` with the hash suggested by Bazel after the dependency is\nfirst loaded.\n\n*/MODULE.bazel*\n\n```starlark\nbazel_dep(name = \"rules_play_routes\")\n\nrules_play_routes_version = \"\u003cCOMMIT\u003e\"\n\narchive_override(\n    module_name = \"rules_play_routes\",\n    integrity = \"\u003cINTEGRITY\u003e\",\n    strip_prefix = \"rules_play_routes-{}\".format(rules_play_routes_version),\n    urls = [\"https://github.com/lucidsoftware/rules_play_routes/archive/refs/heads/{}.zip\".format(rules_play_routes_version)],\n)\n```\n\nBy default, the Scala 3 version of the Play routes compiler will be used. To change the default to\nScala 2.13, add the `--@rules_play_routes//play-routes-toolchain=play-routes-2-13` flag to your\n`.bazelrc` file.\n\nIf you want to use a custom Play routes compiler, you can set up a custom toolchain like so:\n\n*/BUILD.bazel*\n\n```starlark\nload(\"@rules_play_routes//play-routes-toolchain:create-toolchain.bzl\", \"create_play_routes_toolchain\")\n\ncreate_play_routes_toolchain(\n    name = \"play-routes-custom\",\n    play_routes_compiler = \"\u003clabel of your custom Play routes compiler\u003e\",\n)\n```\n\nThen, register your toolchain with Bazel and set it as the default in your `.bazelrc` file:\n\n*/MODULE.bazel*\n\n```starlark\nregister_toolchains(\"//:play-routes-custom\")\n```\n\n*/.bazelrc*\n\n```\ncommon --@rules_play_routes//play-routes-toolchain=play-routes-custom\n```\n\nYou can find the available versions of the Twirl Compiler CLI on maven:\nhttps://mvnrepository.com/artifact/com.lucidchart/play-routes-compiler-cli.\n\n## Usage\n\nThe `play_routes` rule compiles Play routes files to a source jar that can be used with the\n`rules_scala` rules. For example,\n\n```starkark\nload(\"@rules_play_routes//play-routes:play-routes.bzl\", \"play_routes\")\n\nplay_routes(\n    name = \"play-routes\",\n    srcs = [\"conf/routes\"] + glob([\"conf/*.routes\"]),\n    include_play_imports = True,\n    generate_reverse_router = True,\n    routes_imports = [...],\n)\n\nscala_binary(\n    name = \"foo-service\",\n    srcs = glob([\"app/**/*.scala\"]) + [\":play-routes\"],\n    main_class = \"foo.server.RunServer\",\n    deps = [...]\n)\n```\n\n### Overriding the default Play routes compiler\n\nTo override the default Play routes compiler for a single target, you can change the\n`play_routes_toolchain_name` attribute on the `play_routes` target. That attribute can be set to\nthe name of any `play_routes_toolchain` registered with `play_routes_register_toolchains` (and\ncreated using `create_play_routes_toolchain`). By default `play-routes-3` and `play-routes-2-13` are\nvalid values.\n\nFor example:\n```starlark\nplay_routes(\n    name = \"play-routes\",\n    srcs = [\"conf/routes\"] + glob([\"conf/*.routes\"]),\n    include_play_imports = True,\n    generate_reverse_router = True,\n    routes_imports = [...],\n    play_routes_toolchain_name = \"play-routes-2-13\",\n)\n```\n\nSee the [Stardoc documentation](docs/stardoc/play-routes.md) for the full list of options for\n`play_routes`.\n\n### Use with the Play Framework\n\n`play_routes` can be used with [`rules_twirl`](https://github.com/lucidsoftware/rules_twirl) to run\na Play Framework Service. For example\n\n```starlark\ntwirl_templates(\n  name = \"twirl-templates\",\n  source_directory = \"app\",\n  include_play_imports = True,\n  srcs = glob([\"app/**/*.scala.html\"])\n    + glob([\"app/**/*.scala.xml\"])\n    + glob([\"app/**/*.scala.js\"])\n    + glob([\"app/**/*.scala.txt\"]),\n  additional_imports = [...],\n)\n\nplay_routes(\n    name = \"play-routes\",\n    srcs = [\"conf/routes\"] + glob([\"conf/*.routes\"]),\n    include_play_imports = True,\n    generate_reverse_router = True,\n    routes_imports = [...],\n)\n\nscala_binary(\n    name = \"foo-service\",\n    srcs = glob([\"app/**/*.scala\"])  + [\":twirl-templates\", \":play-routes\"],\n    visibility = [\"//visibility:public\"],\n    main_class = \"play.core.server.ProdServerStart\",\n    resources = [\n        \"conf/logback.xml\",\n        # To make your static assets work:\n        \"//public\",\n    ] + glob([\"conf/resources/**/*\"]),\n    resource_strip_prefix = native.package_name(),\n    classpath_resources = [\"conf/application.conf\"],\n    jvm_flags = [\n    \t  \"-Dhttp.port=9000\",\n    \t  \"-Dapplication.name=foo-service\",\n    ],\n    deps = [...],\n)\n```\n\nFor static assets to work, put this into your `public/BUILD` file:\n\n```starlark\nfilegroup(\n    name = \"public\",\n    srcs = glob([\"**/*\"]),\n    visibility = [\"//visibility:public\"],\n)\n```\n\nIf you want to have webjars support\n(https://www.playframework.com/documentation/3.0.x/AssetsOverview#WebJars), then check out\nhttps://github.com/gergelyfabian/rules_play_utils.\n\n## Development\n\n### Command Line Play Routes Compiler\n\nThis project consists of the Play routes Bazel rules and a command line Play routes compiler. The\ncommand line compiler can be built with\n```bash\nbazel build //play-routes-compiler-cli:play-routes-compiler-cli-3\n```\n\nIt can be run with\n```bash\nbazel run //play-routes-compiler-cli:play-routes-compiler-cli-3\n```\n\nThere is a 2.13 verison of the routes compiler: `//play-routes-compiler-cli:play-routes-compiler-cli-2-13`\n\n### Testing\nAll tests can be run using\n\n```bash\ntest/run_all_tests.sh\n```\n\nThey can also be run using\n```bash\nbazel test //test/...\n```\n\n### Updating Third Party Dependencies\n\nWe use [rules_jvm_external](https://github.com/bazelbuild/rules_jvm_external) to import\nthird party dependencies.\n\nTo make changes to the dependencies, simply update the appropriate `maven.install` call in\n`MODULE.bazel`, and then update the dependencies json file used by `rules_jvm_external` by running\nthe following script:\n\n```bash\nscripts/gen-deps.sh\n```\nNever modify the dependencies json file directly.\n\n### Updating Stardoc\n\nBefore pushing your changes, make sure you update the documentation by running the following script:\n\n```bash\nscripts/gen-docs.sh\n```\n\nFailure to do so will result in CI failing.\n\n## Releasing\n\nTo release a new version to Maven Central:\n 1. Push a tag with this syntax: `P1.P2.P3` where `P1.P2.P3` is the Play version, e.g., `3.0.4`\n 2. Once the build completes (including the publish step), find the\n    [staging repo in Sonatype](https://oss.sonatype.org/#stagingRepositories) (assuming you're\n    signed in and have access to the project)\n 3. Verify all the artifacts are on the staging Repository, and then close it through the Sonatype GUI\n 4. Once Sonatype's pre-release checks on the repository complete, release it through the Sonatype GUI\n 5. Verify the artifact's present in\n    [Maven Central](https://search.maven.org/search?q=com.lucidchart) (it can take multiple hours\n    for everything to sync)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidsoftware%2Frules_play_routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidsoftware%2Frules_play_routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidsoftware%2Frules_play_routes/lists"}