Skip to content

Commit e8b3dc6

Browse files
committed
Upgrade rules_scala, scala and finagle versions
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent eae1d77 commit e8b3dc6

File tree

4 files changed

+90
-37
lines changed

4 files changed

+90
-37
lines changed

WORKSPACE

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ load("@bazel_features//:deps.bzl", "bazel_features_deps")
2323

2424
bazel_features_deps()
2525

26+
load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo")
27+
28+
compatibility_proxy_repo()
29+
2630
# Order is important. Try to go from most basic/primitive to higher level packages.
2731
# - go_rules_dependencies
2832
# - protobuf_deps
@@ -49,6 +53,10 @@ go_register_toolchains()
4953
# gazelle:repository_macro go_deps.bzl%pl_go_dependencies
5054
pl_go_dependencies()
5155

56+
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
57+
58+
rules_java_dependencies()
59+
5260
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
5361

5462
protobuf_deps()
@@ -57,17 +65,34 @@ load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
5765

5866
grpc_deps()
5967

60-
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
68+
load("@io_bazel_rules_scala//scala:deps.bzl", "rules_scala_dependencies")
6169

62-
scala_version = "2.13.6"
70+
rules_scala_dependencies()
6371

64-
scala_config(scala_version = scala_version)
72+
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
6573

66-
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
74+
scala_version = "2.13.16"
6775

68-
scala_repositories()
76+
scala_config(scala_version = scala_version)
6977

70-
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
78+
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains", "scala_toolchains")
79+
80+
scala_toolchains(
81+
fetch_sources = True,
82+
twitter_scrooge = {
83+
"libthrift": "@thrift_deps//:org_apache_thrift_libthrift",
84+
# Use scrooge_core_with_finagle to include finagle on the compile classpath
85+
# for generated thrift service code. Must use @px// prefix to reference
86+
# the main workspace from within the generated @rules_scala_toolchains repo.
87+
"scrooge_core": "@px//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:scrooge_core_with_finagle",
88+
"scrooge_generator": "@thrift_deps//:com_twitter_scrooge_generator_2_13",
89+
"util_core": "@thrift_deps//:com_twitter_util_core_2_13",
90+
"util_logging": "@thrift_deps//:com_twitter_util_logging_2_13",
91+
"javax_annotation_api": "@thrift_deps//:javax_annotation_javax_annotation_api",
92+
"mustache": "@thrift_deps//:com_github_spullara_mustache_java_compiler",
93+
"scopt": "@thrift_deps//:com_github_scopt_scopt_2_13",
94+
},
95+
)
7196

7297
scala_register_toolchains()
7398

@@ -187,26 +212,6 @@ load("@thrift_deps//:defs.bzl", thrift_pinned_maven_install = "pinned_maven_inst
187212

188213
thrift_pinned_maven_install()
189214

190-
# twitter_scrooge will use incompatible versions of @scrooge_jars and @thrift_jars.
191-
# These bind statements ensure that the correct versions of finagle libthrift, scrooge core
192-
# and scrooge generator are used to ensure successful compilation.
193-
# See https://github.com/bazelbuild/rules_scala/issues/592 and
194-
# https://github.com/bazelbuild/rules_scala/pull/847 for more details.
195-
bind(
196-
name = "io_bazel_rules_scala/dependency/thrift/scrooge_core",
197-
actual = "//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:scrooge_jars",
198-
)
199-
200-
bind(
201-
name = "io_bazel_rules_scala/dependency/thrift/scrooge_generator",
202-
actual = "//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:scrooge_jars",
203-
)
204-
205-
bind(
206-
name = "io_bazel_rules_scala/dependency/thrift/libthrift",
207-
actual = "//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:thrift_jars",
208-
)
209-
210215
# gazelle:repo bazel_gazelle
211216
# Gazelle depes need to be loaded last to make sure they don't override our dependencies.
212217
# The first one wins when it comes to package declaration.

bazel/repository_locations.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,11 @@ REPOSITORY_LOCATIONS = dict(
431431
],
432432
),
433433
io_bazel_rules_scala = dict(
434-
sha256 = "6e9191363357d30b144e7306fec74deea2c7f1de63f3ed32028838116c239e8a",
434+
sha256 = "6a900a39bf643c5c9308c8200f9a61e27588dc54a67aa08fcfc798f25add4f7b",
435435
urls = [
436-
"https://github.com/bazelbuild/rules_scala/archive/4ba3780fcba8d26980daff4639abc6f18517308b.tar.gz",
436+
"https://github.com/bazelbuild/rules_scala/releases/download/v7.1.0/rules_scala-v7.1.0.tar.gz",
437437
],
438-
strip_prefix = "rules_scala-4ba3780fcba8d26980daff4639abc6f18517308b",
438+
strip_prefix = "rules_scala-7.1.0",
439439
),
440440
org_tensorflow = dict(
441441
sha256 = "a640d1f97be316a09301dfc9347e3d929ad4d9a2336e3ca23c32c93b0ff7e5d0",
@@ -449,9 +449,9 @@ REPOSITORY_LOCATIONS = dict(
449449
manual_license_name = "libc/musl",
450450
),
451451
rules_cc = dict(
452-
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
453-
strip_prefix = "rules_cc-0.0.17",
454-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
452+
sha256 = "a2fdfde2ab9b2176bd6a33afca14458039023edb1dd2e73e6823810809df4027",
453+
strip_prefix = "rules_cc-0.2.14",
454+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.2.14/rules_cc-0.2.14.tar.gz"],
455455
),
456456
rules_foreign_cc = dict(
457457
sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc",

bazel/thrift.bzl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,29 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616

17-
load("@io_bazel_rules_scala//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge")
1817
load("@rules_jvm_external//:defs.bzl", "maven_install")
1918

2019
def thrift_deps(scala_version):
21-
twitter_scrooge()
20+
# twitter_scrooge is now set up via scala_toolchains(twitter_scrooge = {...}) in WORKSPACE
2221

23-
finagle_version = "22.7.0"
22+
finagle_version = "24.2.0"
2423
scala_minor_version = ".".join(scala_version.split(".")[:2])
2524

2625
maven_install(
2726
name = "thrift_deps",
2827
artifacts = [
28+
# Finagle dependencies (needed for generated service code)
2929
"com.twitter:finagle-thriftmux_%s:%s" % (scala_minor_version, finagle_version),
30+
"com.twitter:finagle-thrift_%s:%s" % (scala_minor_version, finagle_version),
3031
"com.twitter:finagle-mux_%s:%s" % (scala_minor_version, finagle_version),
3132
"com.twitter:finagle-core_%s:%s" % (scala_minor_version, finagle_version),
33+
"com.twitter:finagle-http_%s:%s" % (scala_minor_version, finagle_version),
34+
# Scrooge dependencies (needed for code generation toolchain)
3235
"com.twitter:scrooge-core_%s:%s" % (scala_minor_version, finagle_version),
3336
"com.twitter:scrooge-generator_%s:%s" % (scala_minor_version, finagle_version),
34-
"com.twitter:finagle-http_%s:%s" % (scala_minor_version, finagle_version),
35-
"org.apache.thrift:libthrift:0.10.0",
37+
"com.twitter:util-core_%s:%s" % (scala_minor_version, finagle_version),
38+
"com.twitter:util-logging_%s:%s" % (scala_minor_version, finagle_version),
39+
# Logging
3640
"org.slf4j:slf4j-api:1.7.36",
3741
"ch.qos.logback:logback-core:1.2.10",
3842
"ch.qos.logback:logback-classic:1.2.10",

src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux/BUILD.bazel

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ thrift_library(
6767
srcs = glob(["**/*.thrift"]),
6868
)
6969

70+
# Scrooge core with finagle dependencies bundled.
71+
# This is used as the scrooge_core for the toolchain, so that the generated
72+
# service code has access to finagle classes at compile time.
73+
scala_library(
74+
name = "scrooge_core_with_finagle",
75+
visibility = ["//visibility:public"],
76+
exports = [
77+
"@thrift_deps//:com_twitter_finagle_core_2_13",
78+
"@thrift_deps//:com_twitter_finagle_thrift_2_13",
79+
"@thrift_deps//:com_twitter_scrooge_core_2_13",
80+
],
81+
)
82+
7083
scala_library(
7184
name = "scrooge_jars",
7285
visibility = ["//visibility:public"],
@@ -81,6 +94,31 @@ scala_library(
8194
],
8295
)
8396

97+
# Runtime dependencies for generated scrooge code (for downstream consumers)
98+
scala_library(
99+
name = "scrooge_runtime_deps",
100+
visibility = ["//visibility:public"],
101+
exports = [
102+
"@thrift_deps//:com_twitter_finagle_core_2_13",
103+
"@thrift_deps//:com_twitter_finagle_thrift_2_13",
104+
"@thrift_deps//:com_twitter_scrooge_core_2_13",
105+
"@thrift_deps//:org_apache_thrift_libthrift",
106+
],
107+
)
108+
109+
# Full finagle dependencies for Server/Client scala files
110+
scala_library(
111+
name = "finagle_deps",
112+
visibility = ["//visibility:public"],
113+
exports = [
114+
"@thrift_deps//:com_twitter_finagle_core_2_13",
115+
"@thrift_deps//:com_twitter_finagle_http_2_13",
116+
"@thrift_deps//:com_twitter_finagle_mux_2_13",
117+
"@thrift_deps//:com_twitter_finagle_thrift_2_13",
118+
"@thrift_deps//:com_twitter_finagle_thriftmux_2_13",
119+
],
120+
)
121+
84122
scala_library(
85123
name = "thrift_jars",
86124
visibility = ["//visibility:public"],
@@ -94,6 +132,9 @@ scrooge_scala_library(
94132
deps = [
95133
":thrift_library",
96134
],
135+
exports = [
136+
":scrooge_runtime_deps",
137+
],
97138
)
98139

99140
scala_library(
@@ -110,6 +151,7 @@ scala_binary(
110151
srcs = glob(["**/*.scala"]),
111152
main_class = "Server",
112153
deps = [
154+
":finagle_deps",
113155
":thriftmux_scrooge",
114156
],
115157
)
@@ -119,6 +161,7 @@ scala_binary(
119161
srcs = glob(["**/*.scala"]),
120162
main_class = "Client",
121163
deps = [
164+
":finagle_deps",
122165
":thriftmux_scrooge",
123166
],
124167
)
@@ -144,6 +187,7 @@ scala_image(
144187
],
145188
main_class = "Server",
146189
deps = [
190+
":finagle_deps",
147191
":logging",
148192
":thriftmux_scrooge",
149193
],

0 commit comments

Comments
 (0)