Skip to content

Commit c5ad74f

Browse files
committed
feat: Add Kotlin (JVM) support
Provide rules to build Kotlin proto and grpc libraries. Currently upstream Protobuf and gRPC support only JVM-flavour Kotlin. Fixes rules-proto-grpc#139.
1 parent 5c27949 commit c5ad74f

32 files changed

+2282
-142
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ Full documentation for the current and previous versions [can be found here](htt
7676
| [Java](https://rules-proto-grpc.com/en/latest/lang/java.html) | [java_grpc_compile](https://rules-proto-grpc.com/en/latest/lang/java.html#java-grpc-compile) | Generates a Java protobuf and gRPC srcjar file ([example](/example/java/java_grpc_compile)) |
7777
| [Java](https://rules-proto-grpc.com/en/latest/lang/java.html) | [java_proto_library](https://rules-proto-grpc.com/en/latest/lang/java.html#java-proto-library) | Generates a Java protobuf library using ``java_library`` ([example](/example/java/java_proto_library)) |
7878
| [Java](https://rules-proto-grpc.com/en/latest/lang/java.html) | [java_grpc_library](https://rules-proto-grpc.com/en/latest/lang/java.html#java-grpc-library) | Generates a Java protobuf and gRPC library using ``java_library`` ([example](/example/java/java_grpc_library)) |
79+
| [Kotlin](https://rules-proto-grpc.com/en/latest/lang/kotlin.html) | [kotlin_proto_compile](https://rules-proto-grpc.com/en/latest/lang/kotlin.html#kotlin-proto-compile) | Generates a Kotlin (JVM) protobuf srcjar file ([example](/example/kotlin/kotlin_proto_compile)) |
80+
| [Kotlin](https://rules-proto-grpc.com/en/latest/lang/kotlin.html) | [kotlin_grpc_compile](https://rules-proto-grpc.com/en/latest/lang/kotlin.html#kotlin-grpc-compile) | Generates a Kotlin (JVM) protobuf and gRPC srcjar file ([example](/example/kotlin/kotlin_grpc_compile)) |
81+
| [Kotlin](https://rules-proto-grpc.com/en/latest/lang/kotlin.html) | [kotlin_proto_library](https://rules-proto-grpc.com/en/latest/lang/kotlin.html#kotlin-proto-library) | Generates a Kotlin (JVM) protobuf library using ``kt_jvm_library`` ([example](/example/kotlin/kotlin_proto_library)) |
82+
| [Kotlin](https://rules-proto-grpc.com/en/latest/lang/kotlin.html) | [kotlin_grpc_library](https://rules-proto-grpc.com/en/latest/lang/kotlin.html#kotlin-grpc-library) | Generates a Kotlin (JVM) protobuf and gRPC library using ``kt_jvm_library`` ([example](/example/kotlin/kotlin_grpc_library)) |
7983
| [JavaScript](https://rules-proto-grpc.com/en/latest/lang/js.html) | [js_proto_compile](https://rules-proto-grpc.com/en/latest/lang/js.html#js-proto-compile) | Generates JavaScript protobuf ``.js`` and ``.d.ts`` files ([example](/example/js/js_proto_compile)) |
8084
| [JavaScript](https://rules-proto-grpc.com/en/latest/lang/js.html) | [js_grpc_node_compile](https://rules-proto-grpc.com/en/latest/lang/js.html#js-grpc-node-compile) | Generates JavaScript protobuf and gRPC-node ``.js`` and ``.d.ts`` files ([example](/example/js/js_grpc_node_compile)) |
8185
| [JavaScript](https://rules-proto-grpc.com/en/latest/lang/js.html) | [js_grpc_web_compile](https://rules-proto-grpc.com/en/latest/lang/js.html#js-grpc-web-compile) | Generates JavaScript protobuf and gRPC-Web ``.js`` and ``.d.ts`` files ([example](/example/js/js_grpc_web_compile)) |

WORKSPACE

+151-134
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,50 @@ rules_proto_dependencies()
2020

2121
rules_proto_toolchains()
2222

23+
#
24+
# Java
25+
#
26+
load("//java:repositories.bzl", "java_repos")
27+
28+
java_repos()
29+
30+
#
31+
# Kotlin-JVM
32+
#
33+
load("//kotlin:repositories.bzl", "kotlin_repos")
34+
35+
kotlin_repos()
36+
37+
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
38+
39+
kotlin_repositories()
40+
41+
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
42+
43+
kt_register_toolchains()
44+
45+
load("@rules_jvm_external//:defs.bzl", "maven_install")
46+
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
47+
load("@com_github_grpc_grpc_kotlin//:repositories.bzl", "IO_GRPC_GRPC_KOTLIN_ARTIFACTS", "IO_GRPC_GRPC_KOTLIN_OVERRIDE_TARGETS", "grpc_kt_repositories")
48+
49+
maven_install(
50+
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS + IO_GRPC_GRPC_KOTLIN_ARTIFACTS,
51+
generate_compat_repositories = True,
52+
override_targets = dict(IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS.items() +
53+
IO_GRPC_GRPC_KOTLIN_OVERRIDE_TARGETS.items()),
54+
repositories = [
55+
"https://repo.maven.apache.org/maven2/",
56+
],
57+
)
58+
59+
load("@maven//:compat.bzl", "compat_repositories")
60+
61+
compat_repositories()
62+
63+
grpc_java_repositories()
64+
65+
grpc_kt_repositories()
66+
2367
#
2468
# Android
2569
#
@@ -58,23 +102,23 @@ go_repos()
58102
# Load build_bazel_rules_swift before running grpc_deps in C++, since that depends on a very old
59103
# version of build_bazel_apple_support
60104
#
61-
load("//swift:repositories.bzl", "swift_repos")
62-
63-
swift_repos()
64-
65-
load(
66-
"@build_bazel_rules_swift//swift:repositories.bzl",
67-
"swift_rules_dependencies",
68-
)
69-
70-
swift_rules_dependencies()
105+
#load("//swift:repositories.bzl", "swift_repos")
106+
#
107+
#swift_repos()
108+
#
109+
#load(
110+
# "@build_bazel_rules_swift//swift:repositories.bzl",
111+
# "swift_rules_dependencies",
112+
#)
113+
#
114+
#swift_rules_dependencies()
71115

72116
#
73117
# C++
74118
#
75-
load("//cpp:repositories.bzl", "cpp_repos")
76-
77-
cpp_repos()
119+
#load("//cpp:repositories.bzl", "cpp_repos")
120+
#
121+
#cpp_repos()
78122

79123
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
80124

@@ -87,71 +131,53 @@ grpc_extra_deps()
87131
#
88132
# Android
89133
#
90-
load("//android:repositories.bzl", "android_repos")
91-
92-
android_repos()
93-
94-
load("@rules_jvm_external//:defs.bzl", "maven_install")
95-
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
96-
97-
maven_install(
98-
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
99-
generate_compat_repositories = True,
100-
override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS,
101-
repositories = [
102-
"https://repo.maven.apache.org/maven2/",
103-
],
104-
)
105-
106-
load("@maven//:compat.bzl", "compat_repositories")
107-
108-
compat_repositories()
109-
110-
grpc_java_repositories()
111-
112-
load("@build_bazel_rules_android//android:sdk_repository.bzl", "android_sdk_repository")
134+
#load("//android:repositories.bzl", "android_repos")
135+
#
136+
#android_repos()
113137

114-
android_sdk_repository(name = "androidsdk")
138+
#load("@build_bazel_rules_android//android:sdk_repository.bzl", "android_sdk_repository")
139+
#
140+
#android_sdk_repository(name = "androidsdk")
115141

116142
#
117143
# C#/F#
118144
#
119-
load("//csharp:repositories.bzl", "csharp_repos")
120-
121-
csharp_repos()
122-
123-
load("@io_bazel_rules_dotnet//dotnet:deps.bzl", "dotnet_repositories")
124-
125-
dotnet_repositories()
126-
127-
load(
128-
"@io_bazel_rules_dotnet//dotnet:defs.bzl",
129-
"dotnet_register_toolchains",
130-
"dotnet_repositories_nugets",
131-
)
132-
133-
dotnet_register_toolchains()
134-
135-
dotnet_repositories_nugets()
136-
137-
load("@rules_proto_grpc//csharp/nuget:nuget.bzl", nuget_rules_proto_grpc_packages_csharp = "nuget_rules_proto_grpc_packages")
138-
139-
nuget_rules_proto_grpc_packages_csharp()
140-
141-
load("@rules_proto_grpc//fsharp/nuget:nuget.bzl", nuget_rules_proto_grpc_packages_fsharp = "nuget_rules_proto_grpc_packages")
142-
143-
nuget_rules_proto_grpc_packages_fsharp()
145+
#load("//csharp:repositories.bzl", "csharp_repos")
146+
#
147+
#csharp_repos()
148+
#
149+
#load("@io_bazel_rules_dotnet//dotnet:deps.bzl", "dotnet_repositories")
150+
#
151+
#dotnet_repositories()
152+
#
153+
#load(
154+
# "@io_bazel_rules_dotnet//dotnet:defs.bzl",
155+
# "dotnet_register_toolchains",
156+
# "dotnet_repositories_nugets",
157+
#)
158+
#
159+
#dotnet_register_toolchains()
160+
#
161+
#dotnet_repositories_nugets()
162+
#
163+
#load("@rules_proto_grpc//csharp/nuget:nuget.bzl", nuget_rules_proto_grpc_packages_csharp = "nuget_rules_proto_grpc_packages")
164+
#
165+
#nuget_rules_proto_grpc_packages_csharp()
166+
#
167+
#load("@rules_proto_grpc//fsharp/nuget:nuget.bzl", nuget_rules_proto_grpc_packages_fsharp = "nuget_rules_proto_grpc_packages")
168+
#
169+
#nuget_rules_proto_grpc_packages_fsharp()
144170

145171
#
146172
# D
147173
#
148-
load("//d:repositories.bzl", "d_repos")
149-
150-
d_repos()
151-
152-
load("@io_bazel_rules_d//d:d.bzl", "d_repositories")
153-
154-
d_repositories()
174+
#load("//d:repositories.bzl", "d_repos")
175+
#
176+
#d_repos()
177+
#
178+
#load("@io_bazel_rules_d//d:d.bzl", "d_repositories")
179+
#
180+
#d_repositories()
155181

156182
#
157183
# Doc
@@ -181,15 +207,6 @@ load("@grpc_ecosystem_grpc_gateway//:repositories.bzl", "go_repositories")
181207

182208
go_repositories()
183209

184-
#
185-
# Java
186-
#
187-
load("//java:repositories.bzl", "java_repos")
188-
189-
java_repos()
190-
191-
# grpc_java_repositories already called above in android
192-
193210
#
194211
# JavaScript
195212
#
@@ -212,16 +229,16 @@ yarn_install(
212229
#
213230
# Objective-C
214231
#
215-
load("//objc:repositories.bzl", "objc_repos")
216-
217-
objc_repos()
232+
#load("//objc:repositories.bzl", "objc_repos")
233+
#
234+
#objc_repos()
218235

219236
#
220237
# PHP
221238
#
222-
load("//php:repositories.bzl", "php_repos")
223-
224-
php_repos()
239+
#load("//php:repositories.bzl", "php_repos")
240+
#
241+
#php_repos()
225242

226243
#
227244
# Python
@@ -245,64 +262,64 @@ install_deps()
245262
#
246263
# Ruby
247264
#
248-
load("//ruby:repositories.bzl", "ruby_repos")
249-
250-
ruby_repos()
251-
252-
load("@bazelruby_rules_ruby//ruby:deps.bzl", "rules_ruby_dependencies", "rules_ruby_select_sdk")
253-
254-
rules_ruby_dependencies()
255-
256-
rules_ruby_select_sdk(version = "3.0.2")
257-
258-
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle")
259-
260-
ruby_bundle(
261-
name = "rules_proto_grpc_bundle",
262-
gemfile = "@rules_proto_grpc//ruby:Gemfile",
263-
gemfile_lock = "@rules_proto_grpc//ruby:Gemfile.lock",
264-
includes = {"grpc": ["etc"]},
265-
)
265+
#load("//ruby:repositories.bzl", "ruby_repos")
266+
#
267+
#ruby_repos()
268+
#
269+
#load("@bazelruby_rules_ruby//ruby:deps.bzl", "rules_ruby_dependencies", "rules_ruby_select_sdk")
270+
#
271+
#rules_ruby_dependencies()
272+
#
273+
#rules_ruby_select_sdk(version = "3.0.2")
274+
#
275+
#load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle")
276+
#
277+
#ruby_bundle(
278+
# name = "rules_proto_grpc_bundle",
279+
# gemfile = "@rules_proto_grpc//ruby:Gemfile",
280+
# gemfile_lock = "@rules_proto_grpc//ruby:Gemfile.lock",
281+
# includes = {"grpc": ["etc"]},
282+
#)
266283

267284
#
268285
# Rust
269286
#
270-
load("//rust:repositories.bzl", "rust_repos")
271-
272-
rust_repos()
273-
274-
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
275-
276-
rules_rust_dependencies()
277-
278-
rust_register_toolchains(edition = "2021")
287+
#load("//rust:repositories.bzl", "rust_repos")
288+
#
289+
#rust_repos()
290+
#
291+
#load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
292+
#
293+
#rules_rust_dependencies()
294+
#
295+
#rust_register_toolchains(edition = "2021")
279296

280297
#
281298
# Scala
282299
#
283-
load("//scala:repositories.bzl", "MAVEN_ARTIFACTS", "scala_repos")
284-
285-
scala_repos()
286-
287-
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
288-
289-
scala_config()
290-
291-
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
292-
293-
scala_repositories()
294-
295-
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
296-
297-
scala_register_toolchains()
298-
299-
maven_install(
300-
name = "rules_proto_grpc_scala_maven",
301-
artifacts = MAVEN_ARTIFACTS,
302-
repositories = [
303-
"https://repo1.maven.org/maven2",
304-
],
305-
)
300+
#load("//scala:repositories.bzl", "MAVEN_ARTIFACTS", "scala_repos")
301+
#
302+
#scala_repos()
303+
#
304+
#load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
305+
#
306+
#scala_config()
307+
#
308+
#load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
309+
#
310+
#scala_repositories()
311+
#
312+
#load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
313+
#
314+
#scala_register_toolchains()
315+
#
316+
#maven_install(
317+
# name = "rules_proto_grpc_scala_maven",
318+
# artifacts = MAVEN_ARTIFACTS,
319+
# repositories = [
320+
# "https://repo1.maven.org/maven2",
321+
# ],
322+
#)
306323

307324
#
308325
# Swift

docs/index.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ notified of new releases, you can use GitHub's 'Watch Releases Only' on the repo
9292
9393
http_archive(
9494
name = "rules_proto_grpc",
95-
sha256 = "bbe4db93499f5c9414926e46f9e35016999a4e9f6e3522482d3760dc61011070",
96-
strip_prefix = "rules_proto_grpc-4.2.0",
97-
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.2.0.tar.gz"],
95+
sha256 = "{ARCHIVE_TAR_GZ_SHA256}",
96+
strip_prefix = "rules_proto_grpc-{GIT_COMMIT_ID}",
97+
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/{GIT_COMMIT_ID}.tar.gz"],
9898
)
9999
100100
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains", "rules_proto_grpc_repos")

0 commit comments

Comments
 (0)