Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel support #1227

Closed
xinxiao opened this issue Dec 8, 2018 · 3 comments
Closed

Bazel support #1227

xinxiao opened this issue Dec 8, 2018 · 3 comments

Comments

@xinxiao
Copy link

xinxiao commented Dec 8, 2018

Could there be better support for bazel?

@Vincent-M
Copy link

Vincent-M commented Mar 24, 2019

Are you asking about including the Guice's .jar in your Bazel project?

To get Guice to work in Bazel, you can simply use the jar like some examples show:

maven_jar(
    name = "guice_library",
    artifact = "com.google.inject:guice:4.2.2,
    sha1 = "6dacbe18e5eaa7f6c9c36db33b42e7985e94ce77",
)

You targets can then specify "@guice_library//jar" as a dependency to depend on this jar.

You'll also need to include the other 3 .jar mentionned here: https://github.com/google/guice/tree/4.2.2/lib,

maven_jar(
    name = "aopalliance",
    artifact = "aopalliance:aopalliance:1.0",
    sha1 = "0235ba8b489512805ac13a8f9ea77a1ca5ebe3e8",
)

and the other 2 can be obtained in a similar way, or from bazel's "third_party" folder which provides a ton of BUILD rules:
https://github.com/bazelbuild/bazel/tree/master/third_party
For instance in your WORKSPACE, in addition to the maven_jar, you can add :

git_repository(
    name = "bazel_git_repo",
    remote = "https://github.com/bazelbuild/bazel.git",
    tag = "0.17.1",
)

and then in your BUILD files where you need Guice:

deps = [
      # ...  your other depedencies,
      "@guice_library//jar",
      "@bazel_git_repo//third_party:guava",
      "@bazel_git_repo//third_party:jsr330_inject",
      "@aopalliance//jar", 
],

Bazel documentation recommends using http_archive instead of maven_jar, not sure how this would be replaced

@xinxiao
Copy link
Author

xinxiao commented Mar 24, 2019

@Vincent-M Hi, thanks for addressing this. I found current bazel Guice import not simple is because other than importing the Guice core, bazel requires me to import additional dependencies manually. I tried to import Guice through Guice Parent, but this is a pom path rather than a jar import, which is hard to handle in bazel. A comprehensive maven jar route for Guice could be handy in my use case.

@xinxiao
Copy link
Author

xinxiao commented Mar 25, 2019

@Vincent-M It turns out that Bazel has a semi-external tool that could help resolve this issue.
Thanks @keith for guiding me toward the bazel tool.

Details can be found here: bazelbuild/bazel#7822

@xinxiao xinxiao closed this as completed Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants