|
| 1 | +"""Repositories for testing rules_scala itself""" |
| 2 | + |
| 3 | +load("//scala:scala_cross_version.bzl", "default_maven_server_urls") |
| 4 | +load("//scala:scala_maven_import_external.bzl", "java_import_external") |
| 5 | +load( |
| 6 | + "//test/proto_cross_repo_boundary:repo.bzl", |
| 7 | + "proto_cross_repo_boundary_repository", |
| 8 | +) |
| 9 | +load("//test/toolchains:jdk.bzl", "remote_jdk21_repositories") |
| 10 | +load("//third_party/repositories:repositories.bzl", "repositories") |
| 11 | +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 12 | + |
| 13 | +# Once we switch to Bazel 7, uncomment this `load` statement remove the |
| 14 | +# `native.` prefix from `local_repository` and `new_local_repository`. |
| 15 | +# Update //test/proto_cross_repo_boundary:repo.bzl in the same way. |
| 16 | +#load( |
| 17 | +# "@bazel_tools//tools/build_defs/repo:local.bzl", |
| 18 | +# "local_repository", |
| 19 | +# "new_local_repository", |
| 20 | +#) |
| 21 | +load("@rules_java//java:repositories.bzl", "remote_jdk8_repos") |
| 22 | + |
| 23 | +_BUILD_TOOLS_RELEASE = "5.1.0" |
| 24 | + |
| 25 | +def dev_deps_repositories( |
| 26 | + name = "unused_dev_deps_name", |
| 27 | + maven_servers = default_maven_server_urls(), |
| 28 | + fetch_sources = False): |
| 29 | + """Instantiates internal only repos for development and testing |
| 30 | +
|
| 31 | + Once we're using Bazel 7, uncomment the `load()` statement for `local.bzl` |
| 32 | + in this file and remove `native.` from the `native.{,new_}local_repository` |
| 33 | + calls. |
| 34 | +
|
| 35 | + Until then, `dev_deps_repositories()` must be called from `WORKSPACE` or |
| 36 | + `WORKSPACE.bzlmod`, as module extensions won't be able to use it. |
| 37 | +
|
| 38 | + Args: |
| 39 | + name: unused macro parameter to satisfy Buildifier lint rules |
| 40 | + maven_servers: servers to use when resolving Maven artifacts |
| 41 | + fetch_sources: retrieve Maven artifact sources when True |
| 42 | + """ |
| 43 | + http_archive( |
| 44 | + name = "com_github_bazelbuild_buildtools", |
| 45 | + sha256 = "e3bb0dc8b0274ea1aca75f1f8c0c835adbe589708ea89bf698069d0790701ea3", |
| 46 | + strip_prefix = "buildtools-%s" % _BUILD_TOOLS_RELEASE, |
| 47 | + url = ( |
| 48 | + "https://github.com/bazelbuild/buildtools/archive/%s.tar.gz" % |
| 49 | + _BUILD_TOOLS_RELEASE |
| 50 | + ), |
| 51 | + ) |
| 52 | + |
| 53 | + # needed for the cross repo proto test |
| 54 | + proto_cross_repo_boundary_repository() |
| 55 | + |
| 56 | + native.local_repository( |
| 57 | + name = "example_external_workspace", |
| 58 | + path = "third_party/test/example_external_workspace", |
| 59 | + ) |
| 60 | + |
| 61 | + native.new_local_repository( |
| 62 | + name = "test_new_local_repo", |
| 63 | + build_file_content = """ |
| 64 | +filegroup( |
| 65 | + name = "data", |
| 66 | + srcs = glob(["**/*.txt"]), |
| 67 | + visibility = ["//visibility:public"], |
| 68 | +) |
| 69 | +""", |
| 70 | + path = "third_party/test/new_local_repo", |
| 71 | + ) |
| 72 | + |
| 73 | + # bazel's java_import_external has been altered in rules_scala to be a macro |
| 74 | + # based on jvm_import_external in order to allow for other jvm-language |
| 75 | + # imports (e.g. scala_import) the 3rd-party dependency below is using the |
| 76 | + # java_import_external macro in order to make sure no regression with the |
| 77 | + # original java_import_external |
| 78 | + java_import_external( |
| 79 | + name = "org_apache_commons_commons_lang_3_5_without_file", |
| 80 | + generated_linkable_rule_name = "linkable_org_apache_commons_commons_lang_3_5_without_file", |
| 81 | + jar_sha256 = "8ac96fc686512d777fca85e144f196cd7cfe0c0aec23127229497d1a38ff651c", |
| 82 | + jar_urls = ["https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar"], |
| 83 | + licenses = ["notice"], # Apache 2.0 |
| 84 | + neverlink = True, |
| 85 | + testonly_ = True, |
| 86 | + ) |
| 87 | + |
| 88 | + # We need to select based on platform when we use these |
| 89 | + # https://github.com/bazelbuild/bazel/issues/11655 |
| 90 | + remote_jdk8_repos() |
| 91 | + |
| 92 | + repositories( |
| 93 | + fetch_sources = fetch_sources, |
| 94 | + for_artifact_ids = [ |
| 95 | + # test adding a scala jar: |
| 96 | + "com_twitter__scalding_date", |
| 97 | + # test of strict deps (scalac plugin UT + E2E) |
| 98 | + "com_google_guava_guava_21_0_with_file", |
| 99 | + "com_github_jnr_jffi_native", |
| 100 | + "org_apache_commons_commons_lang_3_5", |
| 101 | + "com_google_guava_guava_21_0", |
| 102 | + # test of import external |
| 103 | + # scala maven import external decodes maven artifacts to its parts |
| 104 | + # (group id, artifact id, packaging, version and classifier). To make sure |
| 105 | + # the decoding and then the download url composition are working the artifact example |
| 106 | + # must contain all the different parts and sha256s so the downloaded content will be |
| 107 | + # validated against it |
| 108 | + "org_springframework_spring_core", |
| 109 | + "org_springframework_spring_tx", |
| 110 | + "org_typelevel_kind_projector", |
| 111 | + # For testing that we don't include sources jars to the classpath |
| 112 | + "org_typelevel__cats_core", |
| 113 | + ], |
| 114 | + maven_servers = maven_servers, |
| 115 | + ) |
| 116 | + |
| 117 | + remote_jdk21_repositories() |
0 commit comments