{"id":29376496,"url":"https://github.com/twitter/bazel-multiversion","last_synced_at":"2025-07-09T22:43:15.010Z","repository":{"id":45546334,"uuid":"301100102","full_name":"twitter/bazel-multiversion","owner":"twitter","description":"Bazel rules to resolve, fetch and manage 3rdparty JVM dependencies with support for multiple parallel versions of the same dependency. Powered by Coursier. ","archived":false,"fork":false,"pushed_at":"2023-06-01T14:21:34.000Z","size":696,"stargazers_count":47,"open_issues_count":2,"forks_count":24,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-05-09T19:35:33.611Z","etag":null,"topics":["bazel","bazel-build","bazel-rules","coursier","dependency-manager","java","jvm","kotlin","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":false,"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/twitter.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}},"created_at":"2020-10-04T10:26:50.000Z","updated_at":"2024-03-07T15:06:39.000Z","dependencies_parsed_at":"2023-01-23T02:45:49.095Z","dependency_job_id":null,"html_url":"https://github.com/twitter/bazel-multiversion","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/twitter/bazel-multiversion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Fbazel-multiversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Fbazel-multiversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Fbazel-multiversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Fbazel-multiversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twitter","download_url":"https://codeload.github.com/twitter/bazel-multiversion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitter%2Fbazel-multiversion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264504616,"owners_count":23618831,"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-build","bazel-rules","coursier","dependency-manager","java","jvm","kotlin","scala"],"created_at":"2025-07-09T22:43:14.370Z","updated_at":"2025-07-09T22:43:15.005Z","avatar_url":"https://github.com/twitter.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"bazel-multiversion\n==================\n\nTransitive Maven artifact resolution that supports multiple versions of\nthe same 3rdparty dependency (an alternative to bazelbuild/rules_jvm_external).\n\n## Getting started\n\n```sh\n# Step 1: Clone repo\ngit clone https://github.com/twitter/bazel-multiversion\ncd bazel-multiversion\n\n# Step 2: Build and run code with different versions of Guava\ncd multiversion-example/\nbazel build tricky/...\nbazel run tricky/user/src/main/scala/bincompat:bin-needs-guava24\nbazel run tricky/user/src/main/scala/bincompat:bin-needs-guava29\n```\n\n## Usage\n\nDownload GraalVM native image from https://github.com/twitter/bazel-multiversion/releases,\nand put `multiversion` in your `PATH`.\n\nThere are 3 ways to configure the dependencies.\n\n### BUILDish DSL\n\nBUILDish DSL allows the configuration of dependencies using `BUILD` files\nsimilar to what is currently done using Pants.\nSee `multiversion-example/3rdparty/jvm/` for the examples.\n\nTo regenerate the `3rdparty/jvm_deps.bzl` file,\nrun the following inside the `multiversion-example/` directory:\n\n```sh\n$ multiversion import-build --output-path=3rdparty/jvm_deps.bzl\n```\n\n#### multiversion_config\n\nPlace this at `3rdparty/jvm/BUILD`:\n\n```python\nmultiversion_config(\n  scala_versions = [\"2.12.12\"],\n)\n```\n\nCurrently only one Scala version can be specified.\n\n#### jar_library\n\nPlace `BUILD` files under `3rdparty/jvm/com/google/guava/BUILD` where `com/google/guava` matches the groupid of the external library:\n\n```python\njar_library(\n  name = \"guava\",\n  jars = [\n    jar(\n      org = \"com.google.guava\",\n      name = \"guava\",\n      rev = \"29.0-jre\",\n    )\n  ],\n)\n\njar_library(\n  name = \"guava-24\",\n  jars = [\n    jar(\n      org = \"com.google.guava\",\n      name = \"guava\",\n      rev = \"24.1.1-jre\",\n    ),\n    jar(\n      org = \"org.checkerframework\",\n      name = \"checker-compat-qual\",\n      rev = \"2.0.0\",\n    )\n  ],\n)\n```\n\nFor Scala libraries:\n\n```python\njar_library(\n  name = \"scalameta\",\n  jars = [\n    scala_jar(\n      org = \"org.scalameta\",\n      name = \"scalameta\",\n      rev = \"4.0.0\",\n    )\n  ],\n)\n```\n\nNext, reference the artifacts in the `BUILD` file with their label\n(location of the Guava `BUILD` + `/` + name of the \"target\"):\n\n```python\nscala_library(\n    name=\"hello\",\n    srcs=[\"Hello.scala\"],\n    deps=[\n        \"@maven//:3rdparty/jvm/com/google/guava/guava\",\n    ],\n)\n```\n\n### Workspace setup\n\n```python\nload(\"//3rdparty:jvm_deps.bzl\", \"jvm_deps\")\njvm_deps()\nload(\"@maven//:jvm_deps.bzl\", \"load_jvm_deps\")\nload_jvm_deps()\n```\n\n### YAML or JSON\n\nIf you prefer to configure the dependencies in one file, create `3rdparty.yaml`\nat the root of monorepo instead\nTo regenerate the `3rdparty/jvm_deps.bzl` file, \nrunt the following inside the `multiversion-example/` directory:\n\n```sh\n$ multiversion export --output-path=3rdparty/jvm_deps.bzl\n```\n\nYou can also specify a different path or format for the input configuration using\n`--input-path`:\n\n```sh\n$ multiversion export --input-path=config/3rdparty.json --output-path=3rdparty/jvm_deps.bzl\n```\n\n### Pants\n\n```sh\n$ multiversion pants-export --output-path=3rdparty/jvm_deps.bzl\n```\n\n## Publishing to external repositories\n\nSee [rules_jvm_export](rules_jvm_export/).\n\n## Building from source\n\nSee [DEVELOP](DEVELOP.md).\n\n## License\n\nCopyright Twitter, Inc.\n\nLicensed under the Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitter%2Fbazel-multiversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwitter%2Fbazel-multiversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitter%2Fbazel-multiversion/lists"}