Fetch scala deps from Maven, due to locking to older scalapb with prior method

Protoc plugin and deps are now fetched with maven_install and avoid
pulling deps list from rules_scala
This commit is contained in:
Adam Liddell 2021-09-21 23:20:35 +01:00
parent 28537b2f69
commit d10dbf1248
16 changed files with 170 additions and 175 deletions

View File

@ -249,7 +249,7 @@ rust_repositories()
#
# Scala
#
load("//scala:repositories.bzl", "scala_repos")
load("//scala:repositories.bzl", "MAVEN_ARTIFACTS", "scala_repos")
scala_repos()
@ -265,41 +265,14 @@ load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
load("@rules_jvm_external//:defs.bzl", "maven_install")
scala_proto_repositories()
#
# Scala routeguide
#
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")
jvm_maven_import_external(
name = "com_thesamet_scalapb_scalapb_json4s",
artifact = "com.thesamet.scalapb:scalapb-json4s_2.12:0.7.1",
artifact_sha256 = "6c8771714329464e03104b6851bfdc3e2e4967276e1a9bd2c87c3b5a6d9c53c7",
server_urls = ["https://repo.maven.apache.org/maven2"],
)
jvm_maven_import_external(
name = "org_json4s_json4s_jackson_2_12",
artifact = "org.json4s:json4s-jackson_2.12:3.6.1",
artifact_sha256 = "83b854a39e69f022ad3d7dd3da664623252dc822ed4ed1117304f39115c88043",
server_urls = ["https://repo.maven.apache.org/maven2"],
)
jvm_maven_import_external(
name = "org_json4s_json4s_core_2_12",
artifact = "org.json4s:json4s-core_2.12:3.6.1",
artifact_sha256 = "e0f481509429a24e295b30ba64f567bad95e8d978d0882ec74e6dab291fcdac0",
server_urls = ["https://repo.maven.apache.org/maven2"],
)
jvm_maven_import_external(
name = "org_json4s_json4s_ast_2_12",
artifact = "org.json4s:json4s-ast_2.12:3.6.1",
artifact_sha256 = "39c7de601df28e32eb0c4e3d684ec65bbf2e59af83c6088cda12688d796f7746",
server_urls = ["https://repo.maven.apache.org/maven2"],
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)
#

View File

@ -140,6 +140,9 @@ Scala
*****
- Updated ``rules_scala`` to latest
- Updated ``ScalaPB`` to 0.11.5
- **WORKSPACE update needed**: Dependencies are now fetched with ``maven_install``. You will need to
update your WORKSPACE to match the current example.
Swift
*****
@ -546,7 +549,7 @@ Scala
*****
- Updated ``rules_scala`` to latest master
- `ScalaPB` is now pulled from ``rules_scala``, which uses 0.9.7
- ``ScalaPB`` is now pulled from ``rules_scala``, which uses 0.9.7
- **WORKSPACE update needed**: The ``scala_proto_repositories()`` rule is now needed
Swift

View File

@ -40,7 +40,7 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
.. code-block:: python
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -52,13 +52,19 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)
``BUILD.bazel``
^^^^^^^^^^^^^^^
@ -152,7 +158,7 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
.. code-block:: python
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -164,10 +170,6 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
@ -175,6 +177,16 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)
``BUILD.bazel``
^^^^^^^^^^^^^^^
@ -263,7 +275,7 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
.. code-block:: python
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -275,13 +287,19 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)
``BUILD.bazel``
^^^^^^^^^^^^^^^
@ -382,7 +400,7 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
.. code-block:: python
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -394,10 +412,6 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
@ -405,6 +419,16 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)
``BUILD.bazel``
^^^^^^^^^^^^^^^

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -27,10 +27,6 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
@ -38,3 +34,13 @@ scala_register_toolchains()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -27,10 +27,6 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
@ -38,3 +34,13 @@ scala_register_toolchains()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -27,10 +27,16 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//scala:repositories.bzl", rules_proto_grpc_scala_repos = "scala_repos")
load("@rules_proto_grpc//scala:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_scala_repos = "scala_repos")
rules_proto_grpc_scala_repos()
@ -27,10 +27,16 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)

View File

@ -265,13 +265,6 @@ VERSIONS = {
"ref": "2437e40131072cadc1628726775ff00fa3941a4a",
"sha256": "0701ee4e1cfd59702d780acde907ac657752fbb5c7d08a0ec6f58ebea8cd0efb",
},
"com_github_scalapb_scalapb": {
"type": "http",
"urls": ["https://github.com/scalapb/ScalaPB/releases/download/v0.9.7/scalapbc-0.9.7.zip"], # Last version with protoc plugin bundled?
"sha256": "623f626e97cca119b2a12c4e1d9a3c85aab9f9fd6dcb8dc22b4f704b824da94e",
"strip_prefix": "scalapbc-0.9.7",
"build_file": "@rules_proto_grpc//third_party:BUILD.bazel.com_github_scalapb_scalapb",
},
# Swift
"com_github_grpc_grpc_swift": {
@ -617,9 +610,6 @@ def rules_rust(**kwargs):
def io_bazel_rules_scala(**kwargs):
_generic_dependency("io_bazel_rules_scala", **kwargs)
def com_github_scalapb_scalapb(**kwargs):
_generic_dependency("com_github_scalapb_scalapb", **kwargs)
#
# Swift
#

View File

@ -3,10 +3,7 @@ load("//:defs.bzl", "proto_plugin")
proto_plugin(
name = "scala_plugin",
out = "{name}.jar",
tool = select({
"@bazel_tools//src/conditions:host_windows": "@com_github_scalapb_scalapb//:bin/protoc-gen-scala.bat",
"//conditions:default": "@com_github_scalapb_scalapb//:bin/protoc-gen-scala",
}),
tool = ":scala_pb_plugin_bin",
use_built_in_shell_environment = True,
visibility = ["//visibility:public"],
)
@ -17,10 +14,15 @@ proto_plugin(
options = [
"grpc",
],
tool = select({
"@bazel_tools//src/conditions:host_windows": "@com_github_scalapb_scalapb//:bin/protoc-gen-scala.bat",
"//conditions:default": "@com_github_scalapb_scalapb//:bin/protoc-gen-scala",
}),
tool = ":scala_pb_plugin_bin",
use_built_in_shell_environment = True,
visibility = ["//visibility:public"],
)
java_binary(
name = "scala_pb_plugin_bin",
main_class = "scalapb.ScalaPbCodeGenerator",
runtime_deps = [
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_compilerplugin_2_12",
],
)

View File

@ -14,10 +14,6 @@ scala_library(
],
deps = [
":routeguide_scala_grpc",
"@com_thesamet_scalapb_scalapb_json4s//jar",
"@org_json4s_json4s_ast_2_12//jar",
"@org_json4s_json4s_core_2_12//jar",
"@org_json4s_json4s_jackson_2_12//jar",
] + GRPC_DEPS,
)
@ -47,4 +43,4 @@ scala_binary(
],
)
# TODO: routeguide server implementations
# TODO: routeguide server implementation

View File

@ -23,7 +23,7 @@ class RouteGuideClient(host: String, port: Int) {
val channel =
ManagedChannelBuilder
.forAddress(host, port)
.usePlaintext(true)
.usePlaintext()
.build()
val blockingStub = RouteGuideGrpc.blockingStub(channel)
@ -179,19 +179,6 @@ class RouteGuideClient(host: String, port: Int) {
object RouteGuideClient extends App {
val logger = Logger.getLogger(getClass.getName)
// This isn't working due to some issue with the json4s library - not a priority to solve it
//
// val features: Seq[Feature] = Try {
// RouteGuidePersistence.parseFeatures(RouteGuidePersistence.defaultFeatureFile)
// } recoverWith {
// case e: Throwable =>
// logger.warning("features load failed: " + e)
// Failure(e)
// } getOrElse {
// logger.warning("Can't load feature list from file")
// Seq.empty
// }
val features = RouteGuidePersistence.getFeatures
val port = if (System.getenv("SERVER_PORT") != null) {

View File

@ -3,16 +3,13 @@ package example
import java.net.URL
import java.util.logging.Logger
import scalapb.json4s.JsonFormat
import scala.io.Source
import io.grpc.examples.routeguide.routeguide.{Feature, FeatureDatabase, Point}
import io.grpc.examples.routeguide.routeguide.{Feature, Point}
object RouteGuidePersistence {
val logger: Logger = Logger.getLogger(getClass.getName)
// val defaultFeatureFile: URL = getClass.getClassLoader.getResource("/scala/example/routeguide/route_guide_db.json")
val defaultFeatureFile: URL = getClass.getClassLoader.getResource("scala/example/routeguide/route_guide_db.json")
/**
@ -30,23 +27,4 @@ object RouteGuidePersistence {
features
}
/**
* Parses the JSON input file containing the list of features.
*/
def parseFeatures(file: URL): Seq[Feature] = {
logger.info(s"Loading features from ${file}")
var features: Seq[Feature] = Seq.empty
val input = file.openStream
try {
val source = Source.fromInputStream(input)
try {
val db = JsonFormat.fromJsonString[FeatureDatabase](source.getLines().mkString("\n"))
features = db.feature
logger.info(s"Parsed features from ${file.getPath}")
} finally source.close()
} finally input.close
logger.info(s"Loaded ${features.size} features")
features
}
}

View File

@ -2,7 +2,7 @@
load(
"//:repositories.bzl",
"com_github_scalapb_scalapb",
"GRPC_VERSION",
"io_bazel_rules_scala",
"io_grpc_grpc_java",
"rules_jvm_external",
@ -13,5 +13,12 @@ def scala_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_grpc_grpc_java(**kwargs)
rules_jvm_external(**kwargs)
com_github_scalapb_scalapb(**kwargs)
io_bazel_rules_scala(**kwargs)
MAVEN_ARTIFACTS = [
"io.grpc:grpc-all:1.40.1", # TODO: Remove once past 1.40.1 and uncomment below
#"io.grpc:grpc-all:{}".format(GRPC_VERSION),
"com.thesamet.scalapb:compilerplugin_2.12:0.11.5",
"com.thesamet.scalapb:scalapb-runtime_2.12:0.11.5",
"com.thesamet.scalapb:scalapb-runtime-grpc_2.12:0.11.5",
]

View File

@ -3,7 +3,6 @@
load("//scala:scala_grpc_compile.bzl", "scala_grpc_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
load("@io_bazel_rules_scala//scala_proto/default:default_deps.bzl", "DEFAULT_SCALAPB_COMPILE_DEPS", "DEFAULT_SCALAPB_GRPC_DEPS") # buildifier: disable=load
def scala_grpc_library(name, **kwargs): # buildifier: disable=function-docstring
# Compile protos
@ -28,9 +27,12 @@ def scala_grpc_library(name, **kwargs): # buildifier: disable=function-docstrin
)
GRPC_DEPS = [
# One dependency in this list is not valid outside of rules_scala workspace, fix up. The '//external' check is for
# older rules_scala prior to
# https://github.com/bazelbuild/rules_scala/commit/e9dfbe39fa44a8dc7ab0b9aef46488f215646d9c
"@io_bazel_rules_scala" + dep if not dep.startswith("//external") and not dep.startswith("@") else dep
for dep in DEFAULT_SCALAPB_COMPILE_DEPS
] + DEFAULT_SCALAPB_GRPC_DEPS
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_api",
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_netty",
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_protobuf",
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_stub",
"@rules_proto_grpc_scala_maven//:com_google_protobuf_protobuf_java",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_lenses_2_12",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_scalapb_runtime_grpc_2_12",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_scalapb_runtime_2_12",
]

View File

@ -3,7 +3,6 @@
load("//scala:scala_proto_compile.bzl", "scala_proto_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
load("@io_bazel_rules_scala//scala_proto/default:default_deps.bzl", "DEFAULT_SCALAPB_COMPILE_DEPS", "DEFAULT_SCALAPB_GRPC_DEPS") # buildifier: disable=load
def scala_proto_library(name, **kwargs): # buildifier: disable=function-docstring
# Compile protos
@ -28,9 +27,7 @@ def scala_proto_library(name, **kwargs): # buildifier: disable=function-docstri
)
PROTO_DEPS = [
# One dependency in this list is not valid outside of rules_scala workspace, fix up. The '//external' check is for
# older rules_scala prior to
# https://github.com/bazelbuild/rules_scala/commit/e9dfbe39fa44a8dc7ab0b9aef46488f215646d9c
"@io_bazel_rules_scala" + dep if not dep.startswith("//external") and not dep.startswith("@") else dep
for dep in DEFAULT_SCALAPB_COMPILE_DEPS
"@rules_proto_grpc_scala_maven//:com_google_protobuf_protobuf_java",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_lenses_2_12",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_scalapb_runtime_2_12",
]

View File

@ -1,6 +1,6 @@
package main
var scalaProtoWorkspaceTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:repositories.bzl", rules_proto_grpc_{{ .Lang.Name }}_repos = "{{ .Lang.Name }}_repos")
var scalaProtoWorkspaceTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_{{ .Lang.Name }}_repos = "{{ .Lang.Name }}_repos")
rules_proto_grpc_{{ .Lang.Name }}_repos()
@ -12,15 +12,21 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()`)
scala_register_toolchains()
var scalaGrpcWorkspaceTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:repositories.bzl", rules_proto_grpc_{{ .Lang.Name }}_repos = "{{ .Lang.Name }}_repos")
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)`)
var scalaGrpcWorkspaceTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:repositories.bzl", RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS = "MAVEN_ARTIFACTS", rules_proto_grpc_{{ .Lang.Name }}_repos = "{{ .Lang.Name }}_repos")
rules_proto_grpc_{{ .Lang.Name }}_repos()
@ -32,22 +38,27 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_repositories")
scala_proto_repositories()
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()`)
grpc_java_repositories()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
name = "rules_proto_grpc_scala_maven",
artifacts = RULES_PROTO_GRPC_SCALA_MAVEN_ARTIFACTS,
repositories = [
"https://repo1.maven.org/maven2",
],
)`)
var scalaLibraryRuleTemplateString = `load("//{{ .Lang.Dir }}:{{ .Lang.Name }}_{{ .Rule.Kind }}_compile.bzl", "{{ .Lang.Name }}_{{ .Rule.Kind }}_compile")
load("//internal:compile.bzl", "proto_compile_attrs")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
load("@io_bazel_rules_scala//scala_proto/default:default_deps.bzl", "DEFAULT_SCALAPB_COMPILE_DEPS", "DEFAULT_SCALAPB_GRPC_DEPS") # buildifier: disable=load
def {{ .Rule.Name }}(name, **kwargs): # buildifier: disable=function-docstring
# Compile protos
@ -70,11 +81,9 @@ var scalaProtoLibraryRuleTemplate = mustTemplate(scalaLibraryRuleTemplateString
)
PROTO_DEPS = [
# One dependency in this list is not valid outside of rules_scala workspace, fix up. The '//external' check is for
# older rules_scala prior to
# https://github.com/bazelbuild/rules_scala/commit/e9dfbe39fa44a8dc7ab0b9aef46488f215646d9c
"@io_bazel_rules_scala" + dep if not dep.startswith("//external") and not dep.startswith("@") else dep
for dep in DEFAULT_SCALAPB_COMPILE_DEPS
"@rules_proto_grpc_scala_maven//:com_google_protobuf_protobuf_java",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_lenses_2_12",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_scalapb_runtime_2_12",
]`)
var scalaGrpcLibraryRuleTemplate = mustTemplate(scalaLibraryRuleTemplateString + `
@ -89,12 +98,15 @@ var scalaGrpcLibraryRuleTemplate = mustTemplate(scalaLibraryRuleTemplateString +
)
GRPC_DEPS = [
# One dependency in this list is not valid outside of rules_scala workspace, fix up. The '//external' check is for
# older rules_scala prior to
# https://github.com/bazelbuild/rules_scala/commit/e9dfbe39fa44a8dc7ab0b9aef46488f215646d9c
"@io_bazel_rules_scala" + dep if not dep.startswith("//external") and not dep.startswith("@") else dep
for dep in DEFAULT_SCALAPB_COMPILE_DEPS
] + DEFAULT_SCALAPB_GRPC_DEPS`)
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_api",
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_netty",
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_protobuf",
"@rules_proto_grpc_scala_maven//:io_grpc_grpc_stub",
"@rules_proto_grpc_scala_maven//:com_google_protobuf_protobuf_java",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_lenses_2_12",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_scalapb_runtime_grpc_2_12",
"@rules_proto_grpc_scala_maven//:com_thesamet_scalapb_scalapb_runtime_2_12",
]`)
func makeScala() *Language {
return &Language{