load("//:opencensus_workspace.bzl", "opencensus_java_libraries")
load("@grpc_java//:java_grpc_library.bzl", "java_grpc_library")

opencensus_java_libraries()

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"],
)

java_library(
    name = "opencensus_examples",
    srcs = glob(
        ["src/main/java/**/*.java"],
    ),
    deps = [
        ":helloworld_java_grpc",
        ":helloworld_java_proto",
        "@com_google_guava_guava//jar",
        "@com_google_code_findbugs_jsr305//jar",
        "@io_opencensus_opencensus_api//jar",
        "@io_opencensus_opencensus_contrib_grpc_metrics//jar",
        "@io_opencensus_opencensus_contrib_zpages//jar",
        "@io_opencensus_opencensus_exporter_stats_prometheus//jar",
        "@io_opencensus_opencensus_exporter_stats_stackdriver//jar",
        "@io_opencensus_opencensus_exporter_trace_logging//jar",
        "@io_opencensus_opencensus_exporter_trace_stackdriver//jar",
        "@io_grpc_grpc_core//jar",
        "@io_grpc_grpc_netty//jar",
        "@io_grpc_grpc_protobuf//jar",
        "@io_grpc_grpc_stub//jar",
        "@io_prometheus_simpleclient//jar",
        "@io_prometheus_simpleclient_httpserver//jar",
    ],
    runtime_deps = [
        "@com_google_api_api_common//jar",
        "@com_google_api_gax//jar",
        "@com_google_api_gax_grpc//jar",
        "@com_google_api_grpc_proto_google_cloud_trace_v1//jar",
        "@com_google_api_grpc_proto_google_cloud_trace_v2//jar",
        "@com_google_api_grpc_proto_google_iam_v1//jar",
        "@com_google_api_grpc_proto_google_cloud_monitoring_v3//jar",
        "@com_google_api_grpc_proto_google_common_protos//jar",
        "@com_google_auth_google_auth_library_credentials//jar",
        "@com_google_auth_google_auth_library_oauth2_http//jar",
        "@com_google_cloud_google_cloud_core//jar",
        "@com_google_cloud_google_cloud_core_grpc//jar",
        "@com_google_cloud_google_cloud_monitoring//jar",
        "@com_google_cloud_google_cloud_trace//jar",
        "@com_google_http_client_google_http_client//jar",
        "@com_google_http_client_google_http_client_jackson2//jar",
        "@com_google_instrumentation_instrumentation_api//jar",
        "@com_google_protobuf_protobuf_java//jar",
        "@com_google_protobuf_protobuf_java_util//jar",
        "@commons_codec_commons_codec//jar",
        "@commons_logging_commons_logging//jar",

        "@com_lmax_disruptor//jar",
        "@io_grpc_grpc_context//jar",
        "@io_grpc_grpc_auth//jar",
        "@io_grpc_grpc_protobuf_lite//jar",
        "@io_netty_netty_buffer//jar",
        "@io_netty_netty_common//jar",
        "@io_netty_netty_codec//jar",
        "@io_netty_netty_codec_socks//jar",
        "@io_netty_netty_codec_http//jar",
        "@io_netty_netty_codec_http2//jar",
        "@io_netty_netty_handler//jar",
        "@io_netty_netty_handler_proxy//jar",
        "@io_netty_netty_resolver//jar",
        "@io_netty_netty_tcnative_boringssl_static//jar",
        "@io_netty_netty_transport//jar",
        "@io_opencensus_opencensus_impl//jar",
        "@io_opencensus_opencensus_impl_core//jar",
        "@joda_time_joda_time//jar",
        "@org_apache_httpcomponents_httpclient//jar",
        "@org_apache_httpcomponents_httpcore//jar",
        "@org_threeten_threetenbp//jar",
    ],
)

java_binary(
    name = "TagContextExample",
    main_class = "io.opencensus.examples.tags.TagContextExample",
    runtime_deps = [
        ":opencensus_examples",
    ],
)

java_binary(
    name = "MultiSpansTracing",
    main_class = "io.opencensus.examples.trace.MultiSpansTracing",
    runtime_deps = [
        ":opencensus_examples",
    ],
)

java_binary(
    name = "MultiSpansScopedTracing",
    main_class = "io.opencensus.examples.trace.MultiSpansScopedTracing",
    runtime_deps = [
        ":opencensus_examples",
    ],
)

java_binary(
    name = "MultiSpansContextTracing",
    main_class = "io.opencensus.examples.trace.MultiSpansContextTracing",
    runtime_deps = [
        ":opencensus_examples",
    ],
)

java_binary(
    name = "ZPagesTester",
    main_class = "io.opencensus.examples.zpages.ZPagesTester",
    runtime_deps = [
        ":opencensus_examples",
    ],
)

java_binary(
    name = "QuickStart",
    main_class = "io.opencensus.examples.helloworld.QuickStart",
    runtime_deps = [
        ":opencensus_examples",
    ],
)

java_binary(
    name = "HelloWorldClient",
    main_class = "io.opencensus.examples.grpc.helloworld.HelloWorldClient",
    runtime_deps = [
        ":opencensus_examples",
    ],
)

java_binary(
    name = "HelloWorldServer",
    main_class = "io.opencensus.examples.grpc.helloworld.HelloWorldServer",
    runtime_deps = [
        ":opencensus_examples",
    ],
)