tree: 8209c1665e71f6892622fdf637c06efa72d3902a
  1. example/
  2. BUILD.bazel
  3. defs.bzl
  4. deps.bzl
  5. java_grpc_compile.bzl
  6. java_grpc_library.bzl
  7. java_proto_compile.bzl
  8. java_proto_library.bzl
  9. javadoc_library.bzl
  10. README.md
  11. repositories.bzl
java/README.md

Java rules

Rules for generating Java protobuf and gRPC .jar files and libraries using standard Protocol Buffers and gRPC-Java. Libraries are created with the Bazel native java_library

RuleDescription
java_proto_compileGenerates a Java protobuf srcjar artifact
java_grpc_compileGenerates a Java protobuf+gRPC srcjar artifact
java_proto_libraryGenerates a Java protobuf library using java_library
java_grpc_libraryGenerates a Java protobuf+gRPC library using java_library

java_proto_compile

Generates a Java protobuf srcjar artifact

WORKSPACE

load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos="java_repos")

rules_proto_grpc_java_repos()

BUILD.bazel

load("@rules_proto_grpc//java:defs.bzl", "java_proto_compile")

java_proto_compile(
    name = "person_java_proto",
    deps = ["@rules_proto_grpc//example/proto:person_proto"],
)

Attributes

NameTypeMandatoryDefaultDescription
depslist<ProtoInfo>true[]List of labels that provide a ProtoInfo (such as native.proto_library)
verboseintfalse0The verbosity level. Supported values and results are 1: show command, 2: show command and sandbox after running protoc, 3: show command and sandbox before and after running protoc, 4. show env, command, expected outputs and sandbox before and after running protoc

java_grpc_compile

Generates a Java protobuf+gRPC srcjar artifact

WORKSPACE

load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos="java_repos")

rules_proto_grpc_java_repos()

BUILD.bazel

load("@rules_proto_grpc//java:defs.bzl", "java_grpc_compile")

java_grpc_compile(
    name = "greeter_java_grpc",
    deps = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

Attributes

NameTypeMandatoryDefaultDescription
depslist<ProtoInfo>true[]List of labels that provide a ProtoInfo (such as native.proto_library)
verboseintfalse0The verbosity level. Supported values and results are 1: show command, 2: show command and sandbox after running protoc, 3: show command and sandbox before and after running protoc, 4. show env, command, expected outputs and sandbox before and after running protoc

java_proto_library

Generates a Java protobuf library using java_library

WORKSPACE

load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos="java_repos")

rules_proto_grpc_java_repos()

load("@io_grpc_grpc_java//:repositories.bzl", "com_google_guava")

com_google_guava()

BUILD.bazel

load("@rules_proto_grpc//java:defs.bzl", "java_proto_library")

java_proto_library(
    name = "person_java_library",
    deps = ["@rules_proto_grpc//example/proto:person_proto"],
)

Attributes

NameTypeMandatoryDefaultDescription
depslist<ProtoInfo>true[]List of labels that provide a ProtoInfo (such as native.proto_library)
verboseintfalse0The verbosity level. Supported values and results are 1: show command, 2: show command and sandbox after running protoc, 3: show command and sandbox before and after running protoc, 4. show env, command, expected outputs and sandbox before and after running protoc

java_grpc_library

Generates a Java protobuf+gRPC library using java_library

WORKSPACE

load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos="java_repos")

rules_proto_grpc_java_repos()

load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")

grpc_java_repositories(
    omit_bazel_skylib = True,
    omit_com_google_protobuf = True,
    omit_com_google_protobuf_javalite = True,
    omit_net_zlib = True,
)

BUILD.bazel

load("@rules_proto_grpc//java:defs.bzl", "java_grpc_library")

java_grpc_library(
    name = "greeter_java_library",
    deps = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)

Attributes

NameTypeMandatoryDefaultDescription
depslist<ProtoInfo>true[]List of labels that provide a ProtoInfo (such as native.proto_library)
verboseintfalse0The verbosity level. Supported values and results are 1: show command, 2: show command and sandbox after running protoc, 3: show command and sandbox before and after running protoc, 4. show env, command, expected outputs and sandbox before and after running protoc