https://kotlinlang.org logo
#getting-started
Title
# getting-started
v

Vinay Reddy

01/30/2021, 10:23 AM
Hello everyone! I'm new to Kotlin and am trying to write a dummy gRPC client/server in Kotlin to get started. The rest of my repository uses the bazel build system, so I was hoping to continue using it. Is this reasonable, or should I be switching to gradle for Kotlin? Assuming bazel works I see that there's https://github.com/grpc/grpc-kotlin to help generate files for my protos, but I don't see very many bazel examples of grpc-kotlin. I'm trying to figure out what to add to my WORKSPACE file (version, sha256 etc.). When I add this to my workspace and try to build my proto I see an error.
Copy code
rules_kotlin_version = "legacy-1.3.0"
rules_kotlin_sha = "4fd769fb0db5d3c6240df8a9500515775101964eebdf85a3f9f0511130885fde"
http_archive(
    name = "io_bazel_rules_kotlin",
    urls = ["<https://github.com/bazelbuild/rules_kotlin/archive/%s.zip>" % rules_kotlin_version],
    type = "zip",
    strip_prefix = "rules_kotlin-%s" % rules_kotlin_version,
    sha256 = rules_kotlin_sha,
)

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
kotlin_repositories()
kt_register_toolchains()

http_archive(
    name = "kt_jvm_grpc",
    sha256 = "ccf10e35ba2ff01f594b8fdd4f2ff2426bfd7ec2a676eace4c116e9d4794e49c",
    urls = ["<https://github.com/grpc/grpc-kotlin/archive/v1.0.0.tar.gz>"],
)
load("@kt_jvm_grpc//:repositories.bzl", "grpc_kt_repositories")
grpc_kt_repositories()
The error is:
Copy code
ERROR: error loading package '': Every .bzl file must have a corresponding package, but '@kt_jvm_grpc//:repositories.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.
This is a public library that I'm simply including. Not sure what to do to fix this error. Would appreciate any help. Thanks!
Looks like I had to run 
bazel run @maven//:pin
  to bring in all the java dependencies. My build succeeded after that. For reference, here's my WORKSPACE file: https://github.com/vinayreddy/experimental/blob/master/WORKSPACE
58 Views