bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
364 stars 275 forks source link

'io_bazel_rules_scala/dependency/thrift/scrooge_core' not declared in package 'external' #302

Open emaxerrno opened 7 years ago

emaxerrno commented 7 years ago

BUILD

load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library")

load("@io_bazel_rules_scala//twitter_scrooge:twitter_scrooge.bzl",
     "scrooge_scala_library")

thrift_library(
    name="jvm_thrift",
    srcs=[
        "common.thrift",
         ....
    ])

scrooge_scala_library(
    name="test_scrooge",
    deps=[":jvm_thrift"],
    visibility=["//visibility:public"])

WORKSPACE

rules_scala_version = "0bac7fe86fdde1cfba3bb2c8a04de5e12de47bcd"  # update this as needed
http_archive(
    name="io_bazel_rules_scala",
    url="https://github.com/bazelbuild/rules_scala/archive/%s.zip" %
    rules_scala_version,
    type="zip",
    strip_prefix="rules_scala-%s" % rules_scala_version)

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()

Errors I'm getting

ERROR: /Users/agallego/...../BUILD:19:1: no such target '//external:io_bazel_rules_scala/dependency/thrift/scrooge_core': target 'io_bazel_rules_scala/dependency/thrift/scrooge_core' not declared in package 'external' defined by /Users/agallego/...../WORKSPACE and referenced by '//concord/thrift:test_scrooge'.
emaxerrno commented 7 years ago

I tried downgrading and changin the version of the rules to multiple tags, including both release versions but no cigar. Right now i'musing th latest master as you can see.

emaxerrno commented 7 years ago

Just upgraded to bazel 0.6.1 to test it out too.

Here is the error i'm getting.

ERROR: /private/var/tmp/_bazel_agallego/e1cc4c0e84fbdec5856b2432269800cf/external/io_bazel_rules_scala/src/scala/io/bazel/rules_scala/scrooge_support/BUILD:16:1: no such target '//external:io_bazel_rules_scala/dependency/thrift/scrooge_generator': target 'io_bazel_rules_scala/dependency/thrift/scrooge_generator' not declared in package 'external' defined by /Users/agallego/workspace/.../WORKSPACE and referenced by '@io_bazel_rules_scala//src/scala/io/bazel/rules_scala/scrooge_support:focused_zip_importer'.
emaxerrno commented 7 years ago

it says I'll have to have a referenced 'external' on my workspace.

johnynek commented 7 years ago

looks like you are not loading the needed jars:

https://github.com/bazelbuild/rules_scala/blob/master/twitter_scrooge/twitter_scrooge.bzl#L10

you need to put twitter_scrooge() in your workspace. We probably need to improve the documentation.

Send a PR to the README maybe that would have helped you?

johnynek commented 7 years ago

by the way, we manually set up the jars when we want to set up other versions.

emaxerrno commented 7 years ago

oh Awesome, still new to bazel. Do i just use your bazel-deps proj on scrooge?

This worked! will submit a PR. though with_finagle=True fails. Missing dep.

johnynek commented 7 years ago

I guess we don't have a test for with_finagle in the repo. That's a shame.

bazel-deps is what we use and then use our own bind statements in the workspace to set up the particular deps instead of twitter_scrooge(). There are still some rough edges with setup and documentation. Thanks for wading through them.

emaxerrno commented 7 years ago

I've tried a few combinations of the these bazel-deps to get it to compile - at this point, scrooge_generator is generating code as i see compilation errors.

bazel-deps: dependencies.yml

com.twitter:
    finatra-thrift:
      lang: scala
      version: "2.9.0"
    finatra-http:
      lang: scala
      version: "2.9.0"
    scrooge-core:
      lang: scala
      version: "4.20.0"
    scrooge-generator:
      lang: scala
      version: "4.20.0"
    finagle-core:
      lang: scala
      version: "7.1.0"
    finagle-stats:
      lang: scala
      version: "7.1.0"
    util-collection:
      lang: scala
      version: "7.1.0"
    util-core:
      lang: scala
      version: "7.1.0"
    bijection-scrooge:
      lang: scala
      version: "0.9.2"

my bindings:

bind(
    name='io_bazel_rules_scala/dependency/thrift/libthrift',
    actual='@org_apache_thrift_libthrift//jar')
bind(
    name='io_bazel_rules_scala/dependency/thrift/scrooge_core',
    actual='@com_twitter_scrooge_core_2_11//jar')
bind(
    name='io_bazel_rules_scala/dependency/thrift/scrooge_generator',
    actual='@com_twitter_scrooge_generator_2_11//jar')
bind(
    name='io_bazel_rules_scala/dependency/thrift/util_core',
    actual='@com_twitter_util_core_2_11//jar')
bind(
    name='io_bazel_rules_scala/dependency/thrift/util_logging',
    actual='@com_twitter_util_logging_2_11//jar')

target

scrooge_scala_library(
    name="test_scrooge",
    deps=[
        ":test_jvm_thrift",
        "//3rdparty/jvm/com/twitter:scrooge_core",
        "//3rdparty/jvm/com/twitter:finagle_stats",
        "//3rdparty/jvm/com/twitter:finagle_core",
        "//3rdparty/jvm/com/twitter:finagle_thrift",
        "//3rdparty/jvm/com/twitter:util_core"
    ],
    with_finagle=True,
    visibility=["//visibility:public"])

compilation errors

It can't find the finagle_stats which is obvi there.

bazel-out/local-fastbuild/bin/concord/thrift/gen_concord/tmp2959407523442130907/.../tf/scheduling/SchedulerService$FinagleService.scala:125: error: not found: type Counter
    requestsCounter: Counter,

am I missing a bind ?

Thanks!

emaxerrno commented 6 years ago

so this works.

scrooge_scala_library(
    name="xxx_scrooge",
    deps=[
        ":xxxx_dependency_thrift",

        "//3rdparty/jvm/com/twitter:scrooge_core",
        "//3rdparty/jvm/com/twitter:finagle_thrift",
        "//3rdparty/jvm/com/twitter:finagle_zipkin",
        "//3rdparty/jvm/com/twitter:finagle_core",
        "//3rdparty/jvm/com/twitter:finagle_stats",
        "//3rdparty/jvm/com/twitter:finagle_http",
        "//3rdparty/jvm/com/twitter:finagle_base_http",
        "//3rdparty/jvm/com/twitter:inject_core",
        "//3rdparty/jvm/com/twitter:inject_app",
        "//3rdparty/jvm/com/twitter:inject_utils",
        "//3rdparty/jvm/com/twitter:inject_server",
        "//3rdparty/jvm/com/twitter:inject_modules",
        "//3rdparty/jvm/com/twitter:inject_thrift",
        "//3rdparty/jvm/com/twitter:util_core",
        "//3rdparty/jvm/com/twitter:util_app",
        "//3rdparty/jvm/com/twitter:util_stats",

        "//3rdparty/jvm/org/apache/thrift:libthrift",

    ],
    with_finagle=True,
    visibility=["//visibility:public"])

The MAIN caveat was to use libthrift 0.8.0

emaxerrno commented 6 years ago

I'm going to prune deps until it compiles w/ the fewest deps, but wanted to put it here in case is helpful to someone else and while i wait for approval to submit pr from the comany.

johnynek commented 6 years ago

Thanks for the updates!

On Wed, Oct 18, 2017 at 6:07 AM, Alexander Gallego <notifications@github.com

wrote:

I'm going to prune deps until it compiles w/ the fewest deps, but wanted to put it here in case is helpful to someone else and while i wait for approval to submit pr from the comany.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/rules_scala/issues/302#issuecomment-337642617, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEJdoxl1mD208MEqD0HysO6pi0zEwHNks5stiIvgaJpZM4P3Q21 .

-- P. Oscar Boykin, Ph.D. | http://twitter.com/posco | http://pobox.com/~boykin