|
1 |
| -############################################################################### |
2 |
| -# Bazel now uses Bzlmod by default to manage external dependencies. |
3 |
| -# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. |
4 |
| -# |
5 |
| -# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 |
6 |
| -############################################################################### |
| 1 | +module(name = "rules_scala_annex") |
| 2 | + |
| 3 | +bazel_dep(name = "bazel_skylib", version = "1.7.1") |
| 4 | + |
| 5 | +bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True) |
| 6 | + |
| 7 | +bazel_dep(name = "rules_java", version = "7.12.2") |
| 8 | +bazel_dep(name = "rules_jvm_external", version = "6.5") |
| 9 | + |
| 10 | +bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True) |
| 11 | +bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True) |
| 12 | + |
| 13 | +register_toolchains( |
| 14 | + "//:annex_scalafmt", |
| 15 | + "//:repository_default_toolchain_21_definition", |
| 16 | + "//rules/scala_proto:scalapb_scala_proto_toolchain", |
| 17 | + "//src/main/scala:annex_bootstrap_2_13", |
| 18 | + "//src/main/scala:annex_bootstrap_3", |
| 19 | + "//src/main/scala:annex_zinc_2_13", |
| 20 | + "//src/main/scala:annex_zinc_3", |
| 21 | +) |
| 22 | + |
| 23 | +# Please ensure these stay up-to-date with the versions in `/rules/scala/versions.bzl`, |
| 24 | +# `/tests/MODULE.bazel`, and `/MODULE.bazel`. Unfortunately, `MODULE.bazel` files can't call `load`, |
| 25 | +# so we have to copy them here. |
| 26 | +scala_2_12_version = "2.12.19" |
| 27 | + |
| 28 | +scala_2_13_version = "2.13.15" |
| 29 | + |
| 30 | +scala_3_version = "3.5.2" |
| 31 | + |
| 32 | +scalapb_version = "0.11.17" |
| 33 | + |
| 34 | +zinc_version = "1.10.4" |
| 35 | + |
| 36 | +annex = use_extension("@rules_jvm_external//:extensions.bzl", "maven") |
| 37 | +annex.install( |
| 38 | + name = "annex", |
| 39 | + artifacts = [ |
| 40 | + "ch.epfl.scala:bloop-frontend_2.12:1.0.0", |
| 41 | + "com.thesamet.scalapb:lenses_2.13:{}".format(scalapb_version), |
| 42 | + "com.thesamet.scalapb:scalapb-runtime_2.13:{}".format(scalapb_version), |
| 43 | + "net.sourceforge.argparse4j:argparse4j:0.8.1", |
| 44 | + "org.jacoco:org.jacoco.core:0.7.5.201505241946", |
| 45 | + "org.scala-lang:scala-compiler:{}".format(scala_2_13_version), |
| 46 | + "org.scala-lang:scala-library:{}".format(scala_2_13_version), |
| 47 | + "org.scala-lang:scala-reflect:{}".format(scala_2_13_version), |
| 48 | + "org.scala-lang:scala3-compiler_3:{}".format(scala_3_version), |
| 49 | + "org.scala-lang:scala3-library_3:{}".format(scala_3_version), |
| 50 | + "org.scala-sbt:compiler-interface:{}".format(zinc_version), |
| 51 | + "org.scala-sbt:io_2.13:1.10.1", |
| 52 | + "org.scala-sbt:test-interface:1.0", |
| 53 | + "org.scala-sbt:util-interface:{}".format(zinc_version), |
| 54 | + "org.scala-sbt:util-logging_2.13:{}".format(zinc_version), |
| 55 | + "org.scala-sbt:zinc_2.13:{}".format(zinc_version), |
| 56 | + "org.scala-sbt:zinc-apiinfo_2.13:{}".format(zinc_version), |
| 57 | + "org.scala-sbt:zinc-classpath_2.13:{}".format(zinc_version), |
| 58 | + "org.scala-sbt:zinc-compile-core_2.13:{}".format(zinc_version), |
| 59 | + "org.scala-sbt:zinc-core_2.13:{}".format(zinc_version), |
| 60 | + "org.scala-sbt:zinc-persist_2.13:{}".format(zinc_version), |
| 61 | + ], |
| 62 | + fetch_sources = True, |
| 63 | + lock_file = "//:annex_install.json", |
| 64 | + repositories = [ |
| 65 | + "https://repo.maven.apache.org/maven2", |
| 66 | + "https://maven-central.storage-download.googleapis.com/maven2", |
| 67 | + "https://mirror.bazel.build/repo1.maven.org/maven2", |
| 68 | + ], |
| 69 | +) |
| 70 | + |
| 71 | +# The compiler bridge has a dependency on compiler-interface, which has a dependency on the Scala 2 |
| 72 | +# library. We need to set this to neverlink = True to avoid this the Scala 2 library being pulled |
| 73 | +# onto the Scala 3, and other Scala versions like 2.12, compiler classpath during runtime. |
| 74 | +annex.artifact( |
| 75 | + name = "annex", |
| 76 | + artifact = "scala3-sbt-bridge", |
| 77 | + group = "org.scala-lang", |
| 78 | + neverlink = True, |
| 79 | + version = scala_3_version, |
| 80 | +) |
| 81 | + |
| 82 | +# The compiler bridge has a dependency on compiler-interface, which has a dependency on the Scala 2 |
| 83 | +# library. We need to set this to neverlink = True to avoid this the Scala 2 library being pulled |
| 84 | +# onto the Scala 3, and other Scala versions like 2.12, compiler classpath during runtime. |
| 85 | +annex.artifact( |
| 86 | + name = "annex", |
| 87 | + artifact = "compiler-bridge_2.13", |
| 88 | + group = "org.scala-sbt", |
| 89 | + neverlink = True, |
| 90 | + version = zinc_version, |
| 91 | +) |
| 92 | +use_repo(annex, "annex") |
| 93 | + |
| 94 | +annex_scalafmt = use_extension("@rules_jvm_external//:extensions.bzl", "maven") |
| 95 | +annex_scalafmt.install( |
| 96 | + name = "annex_scalafmt", |
| 97 | + artifacts = [ |
| 98 | + "org.scalameta:parsers_2.13:4.9.7", |
| 99 | + "org.scalameta:metaconfig-core_2.13:0.13.0", |
| 100 | + "org.scalameta:scalafmt-core_2.13:3.8.2", |
| 101 | + ], |
| 102 | + fetch_sources = True, |
| 103 | + lock_file = "//:annex_scalafmt_install.json", |
| 104 | + repositories = [ |
| 105 | + "https://repo.maven.apache.org/maven2", |
| 106 | + "https://maven-central.storage-download.googleapis.com/maven2", |
| 107 | + "https://mirror.bazel.build/repo1.maven.org/maven2", |
| 108 | + ], |
| 109 | +) |
| 110 | +use_repo(annex_scalafmt, "annex_scalafmt") |
| 111 | + |
| 112 | +annex_proto = use_extension("@rules_jvm_external//:extensions.bzl", "maven") |
| 113 | +annex_proto.install( |
| 114 | + name = "annex_proto", |
| 115 | + artifacts = [ |
| 116 | + "com.github.os72:protoc-jar:3.11.4", |
| 117 | + "com.thesamet.scalapb:compilerplugin_2.13:0.11.17", |
| 118 | + "com.thesamet.scalapb:protoc-bridge_2.13:0.9.7", |
| 119 | + ], |
| 120 | + fetch_sources = True, |
| 121 | + lock_file = "//:annex_proto_install.json", |
| 122 | + repositories = [ |
| 123 | + "https://repo.maven.apache.org/maven2", |
| 124 | + "https://maven-central.storage-download.googleapis.com/maven2", |
| 125 | + "https://mirror.bazel.build/repo1.maven.org/maven2", |
| 126 | + ], |
| 127 | +) |
| 128 | +use_repo(annex_proto, "annex_proto") |
| 129 | + |
| 130 | +java_launcher_version = "7.4.1" |
| 131 | + |
| 132 | +java_launcher_template_sha = "ee4aa47ae5e639632c67be5cc0ccbc4e941a67a1b884a1ce0c4329357a4b62b2" |
| 133 | + |
| 134 | +java_stub_template_url = ( |
| 135 | + "raw.githubusercontent.com/bazelbuild/bazel/" + |
| 136 | + java_launcher_version + |
| 137 | + "/src/main/java/com/google/devtools/build/lib/bazel/rules/java/" + |
| 138 | + "java_stub_template.txt" |
| 139 | +) |
| 140 | + |
| 141 | +http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") |
| 142 | + |
| 143 | +http_file( |
| 144 | + name = "anx_java_stub_template", |
| 145 | + sha256 = java_launcher_template_sha, |
| 146 | + urls = ["https://%s" % java_stub_template_url], |
| 147 | +) |
0 commit comments