{"id":18737053,"url":"https://github.com/higherkindness/rules_scala","last_synced_at":"2025-04-12T19:32:13.943Z","repository":{"id":51006109,"uuid":"121477142","full_name":"higherkindness/rules_scala","owner":"higherkindness","description":"Robust and featureful Bazel rules for Scala","archived":true,"fork":false,"pushed_at":"2023-09-18T21:29:38.000Z","size":1286,"stargazers_count":67,"open_issues_count":39,"forks_count":29,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-04T22:36:00.346Z","etag":null,"topics":["bazel","bazel-rules","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/higherkindness.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-14T06:06:51.000Z","updated_at":"2025-03-02T21:30:38.000Z","dependencies_parsed_at":"2024-11-07T15:28:03.942Z","dependency_job_id":"12d6840d-a4c3-4121-b92e-0acb5c778b87","html_url":"https://github.com/higherkindness/rules_scala","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/higherkindness%2Frules_scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/higherkindness%2Frules_scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/higherkindness%2Frules_scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/higherkindness%2Frules_scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/higherkindness","download_url":"https://codeload.github.com/higherkindness/rules_scala/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248621260,"owners_count":21134789,"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","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","bazel-rules","scala"],"created_at":"2024-11-07T15:23:30.511Z","updated_at":"2025-04-12T19:32:13.476Z","avatar_url":"https://github.com/higherkindness.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# higherkindness/rules_scala\n\n[![Build Status](https://github.com/higherkindness/rules_scala/workflows/CI/badge.svg)](https://github.com/higherkindness/rules_scala/actions)\n\n`higherkindness/rules_scala` evolved, in part, from the need for Bazel adoption support for large, monorepo Scala projects.\nBazel is wonderful because it makes use of parallelism and caching to vastly improve build times. However, to see these benefits, a project must first be broken down into\ntiny packages and make use of fine-grained dependencies. This is not always a realistic short-term goal for large, monorepo Scala projects.\n\n`higherkindness/rules_scala` allows for the optional use of Zinc incremental compilation to provide a stepping stone for these projects as they migrate to Bazel.\n\n`higherkindness/rules_scala` is written with maintainability and accessibility in mind. It aims to facilitate the transition to Bazel, and to satisfy use cases throughout the Scala ecosystem.\n\n## Principles\n\n1. Support the breadth of the Scala ecosystem.\n2. Follow Bazel best practices.\n3. Be accessible and maintainable.\n4. Have high-quality documentation.\n\nIf the right design principles are kept, implementing additional features should be simple and straightforward.\n\n## Features\n\n* Simple core API modeled after Bazel's Java APIs\n  * [scala_library](docs/stardoc/scala.md#scala_library)\n  * [scala_binary](docs/stardoc/scala.md#scala_binary)\n  * [scala_test](docs/stardoc/scala.md#scala_test)\n  * [scala_import](docs/stardoc/scala.md#scala_import)\n  * [scala_repl](docs/stardoc/scala.md#scala_repl)\n* [Works with all sbt-compatible test frameworks](docs/scala.md#tests)\n* [Advanced Dependency Detection](docs/scala.md#strict--unused-deps)\n  * Errors on indirect and unused dependencies\n  * Buildozer suggestions for dependency errors\n* [Optional Worker strategy](docs/scala.md#workers)\n* [Optional Zinc-based stateful incremental compilation](docs/stateful.md#stateful-compilation)\n* [Scalafmt](docs/scalafmt.md#scalafmt) integration\n* Protobuf support with ScalaPB\n  * [scala_proto_library](docs/stardoc/scala_proto.md#scala_proto_library)\n  * [scala_proto_toolchain](docs/stardoc/scala_proto.md#scala_proto_toolchain)\n* Seamless integration with the [Bazel IntelliJ plugin](https://github.com/bazelbuild/intellij)\n* [Customizable rules](docs/newdocs/phases.md#customizing-the-core-rules)\n* [Multiple Scala versions in one build](docs/newdocs/scala_versions.md#specifying-the-scala-version-to-use), including Scala 3 (Dotty).\n* [Optimal handling of macros and ijars](docs/newdocs/macros.md#macros-and-ijars)\n* [Pass flags to Zinc compiler](docs/newdocs/zinc_flags.md)\n* Modern implementation using Bazel's most idiomatic APIs\n\n## Usage\n\nWORKSPACE\n\n```python\nload(\"@bazel_tools//tools/build_defs/repo:http.bzl\", \"http_archive\")\n\n# Load rules scala annex\nrules_scala_annex_version = \"ae99fcb08bbddfc24fef00d7b13f6c065e1df8d5\"\nrules_scala_annex_sha256 = \"1630fc7ecc7a4ffeabcdef73c7600eab9cf3fd2377db1f69b8ce1927560211ff\"\nhttp_archive(\n    name = \"rules_scala_annex\",\n    sha256 = rules_scala_annex_sha256,\n    strip_prefix = \"rules_scala-{}\".format(rules_scala_annex_version),\n    url = \"https://github.com/higherkindness/rules_scala/archive/{}.zip\".format(rules_scala_annex_version),\n)\n\nrules_jvm_external_tag = \"2.9\"\nrules_jvm_external_sha256 = \"e5b97a31a3e8feed91636f42e19b11c49487b85e5de2f387c999ea14d77c7f45\"\nhttp_archive(\n    name = \"rules_jvm_external\",\n    sha256 = rules_jvm_external_sha256,\n    strip_prefix = \"rules_jvm_external-{}\".format(rules_jvm_external_tag),\n    url = \"https://github.com/bazelbuild/rules_jvm_external/archive/{}.zip\".format(rules_jvm_external_tag),\n)\n\nload(\"@rules_scala_annex//rules/scala:workspace.bzl\", \"scala_register_toolchains\", \"scala_repositories\")\nscala_repositories()\nload(\"@annex//:defs.bzl\", annex_pinned_maven_install = \"pinned_maven_install\")\nannex_pinned_maven_install()\nscala_register_toolchains()\n\nload(\"@rules_scala_annex//rules/scalafmt:workspace.bzl\", \"scalafmt_default_config\", \"scalafmt_repositories\")\nscalafmt_repositories()\nload(\"@annex_scalafmt//:defs.bzl\", annex_scalafmt_pinned_maven_install = \"pinned_maven_install\")\nannex_scalafmt_pinned_maven_install()\nscalafmt_default_config()\n\nload(\"@rules_scala_annex//rules/scala_proto:workspace.bzl\", \"scala_proto_register_toolchains\", \"scala_proto_repositories\",)\nscala_proto_repositories()\nload(\"@annex_proto//:defs.bzl\", annex_proto_pinned_maven_install = \"pinned_maven_install\")\nannex_proto_pinned_maven_install()\nscala_proto_register_toolchains()\n\n# Load bazel skylib and google protobuf\nbazel_skylib_tag = \"1.0.2\"\nbazel_skylib_sha256 = \"97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44\"\nhttp_archive(\n    name = \"bazel_skylib\",\n    sha256 = bazel_skylib_sha256,\n    urls = [\n        \"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{tag}/bazel-skylib-{tag}.tar.gz\".format(tag = bazel_skylib_tag),\n        \"https://github.com/bazelbuild/bazel-skylib/releases/download/{tag}/bazel-skylib-{tag}.tar.gz\".format(tag = bazel_skylib_tag),\n    ],\n)\n\nprotobuf_tag = \"3.10.1\"\nprotobuf_sha256 = \"678d91d8a939a1ef9cb268e1f20c14cd55e40361dc397bb5881e4e1e532679b1\"\nhttp_archive(\n    name = \"com_google_protobuf\",\n    sha256 = protobuf_sha256,\n    strip_prefix = \"protobuf-{}\".format(protobuf_tag),\n    type = \"zip\",\n    url = \"https://github.com/protocolbuffers/protobuf/archive/v{}.zip\".format(protobuf_tag),\n)\n\nload(\"@com_google_protobuf//:protobuf_deps.bzl\", \"protobuf_deps\")\nprotobuf_deps()\n\n# Specify the scala compiler we wish to use; in this case, we'll use the default one specified in rules_scala_annex\nbind(\n    name = \"default_scala\",\n    actual = \"@rules_scala_annex//src/main/scala:zinc_2_12_10\",\n)\n```\n\nBUILD\n\n```python\nload(\"@rules_scala_annex//rules:scala.bzl\", \"scala_library\")\n\nscala_library(\n  name = \"example\",\n  srcs = glob([\"**/*.scala\"])\n)\n```\n\n## Further Documentation\n\nSee [contributing guidlines](CONTRIBUTING.md) for help on contributing to this project.\n\nFor all rules and attributes, see the [Stardoc](docs/stardoc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhigherkindness%2Frules_scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhigherkindness%2Frules_scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhigherkindness%2Frules_scala/lists"}