load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")

proto_library(
    name = "helloworld_proto",
    srcs = ["src/main/proto/helloworld.proto"],
)

java_proto_library(
    name = "helloworld_java_proto",
    deps = [":helloworld_proto"],
)

java_grpc_library(
    name = "helloworld_java_grpc",
    srcs = [":helloworld_proto"],
    deps = [":helloworld_java_proto"],
)

proto_library(
    name = "hello_streaming_proto",
    srcs = [
        "src/main/proto/hello_streaming.proto",
    ],
)

java_proto_library(
    name = "hello_streaming_java_proto",
    deps = [":hello_streaming_proto"],
)

java_grpc_library(
    name = "hello_streaming_java_grpc",
    srcs = [":hello_streaming_proto"],
    deps = [":hello_streaming_java_proto"],
)

proto_library(
    name = "route_guide_proto",
    srcs = ["src/main/proto/route_guide.proto"],
)

java_proto_library(
    name = "route_guide_java_proto",
    deps = [":route_guide_proto"],
)

java_grpc_library(
    name = "route_guide_java_grpc",
    srcs = [":route_guide_proto"],
    deps = [":route_guide_java_proto"],
)

java_library(
    name = "examples",
    testonly = 1,
    srcs = glob(
        ["src/main/java/**/*.java"],
    ),
    resources = glob(
        ["src/main/resources/**"],
    ),
    deps = [
        ":hello_streaming_java_grpc",
        ":hello_streaming_java_proto",
        ":helloworld_java_grpc",
        ":helloworld_java_proto",
        ":route_guide_java_grpc",
        ":route_guide_java_proto",
        "@com_google_api_grpc_proto_google_common_protos//jar",
        "@com_google_code_findbugs_jsr305//jar",
        "@com_google_guava_guava//jar",
        "@com_google_protobuf//:protobuf_java",
        "@com_google_protobuf//:protobuf_java_util",
        "@io_grpc_grpc_java//alts",
        "@io_grpc_grpc_java//core",
        "@io_grpc_grpc_java//netty",
        "@io_grpc_grpc_java//protobuf",
        "@io_grpc_grpc_java//stub",
        "@io_netty_netty_handler//jar",
    ],
)

java_binary(
    name = "hello-world-client",
    testonly = 1,
    main_class = "io.grpc.examples.helloworld.HelloWorldClient",
    runtime_deps = [
        ":examples",
    ],
)

java_binary(
    name = "hello-world-server",
    testonly = 1,
    main_class = "io.grpc.examples.helloworld.HelloWorldServer",
    runtime_deps = [
        ":examples",
    ],
)

java_binary(
    name = "hello-world-alts-client",
    testonly = 1,
    main_class = "io.grpc.examples.alts.HelloWorldAltsClient",
    runtime_deps = [
        ":examples",
        "@io_grpc_grpc_java//alts",
        "@io_grpc_grpc_java//netty",
    ],
)

java_binary(
    name = "hello-world-alts-server",
    testonly = 1,
    main_class = "io.grpc.examples.alts.HelloWorldAltsServer",
    runtime_deps = [
        ":examples",
        "@io_grpc_grpc_java//alts",
        "@io_grpc_grpc_java//netty",
    ],
)

java_binary(
    name = "route-guide-client",
    testonly = 1,
    main_class = "io.grpc.examples.routeguide.RouteGuideClient",
    runtime_deps = [
        ":examples",
    ],
)

java_binary(
    name = "route-guide-server",
    testonly = 1,
    main_class = "io.grpc.examples.routeguide.RouteGuideServer",
    runtime_deps = [
        ":examples",
    ],
)

java_binary(
    name = "manual-flow-control-client",
    testonly = 1,
    main_class = "io.grpc.examples.manualflowcontrol.ManualFlowControlClient",
    runtime_deps = [
        ":examples",
    ],
)

java_binary(
    name = "manual-flow-control-server",
    testonly = 1,
    main_class = "io.grpc.examples.manualflowcontrol.ManualFlowControlServer",
    runtime_deps = [
        ":examples",
    ],
)

java_binary(
    name = "hello-world-tls-client",
    testonly = 1,
    main_class = "io.grpc.examples.helloworldtls.HelloWorldClientTls",
    runtime_deps = [
        ":examples",
        "@io_netty_netty_tcnative_boringssl_static//jar",
    ],
)

java_binary(
    name = "hello-world-tls-server",
    testonly = 1,
    main_class = "io.grpc.examples.helloworldtls.HelloWorldServerTls",
    runtime_deps = [
        ":examples",
        "@io_netty_netty_tcnative_boringssl_static//jar",
    ],
)