Reputation: 6364
How to specify groupid, artifact and version directly in dependencies section of BUILD file using Bazel?
I am trying to convert a simple gradle project to bazel project. Can't really use generate_workspace
since I have a gradle project (not maven).
I am wondering if there is just a easier way to specify GAV in the dependencies itself in the BUILD file so it would look something like this
java_binary(
name = "HelloWorld",
srcs = glob(["src/main/java/**/*.java"]),
resources = glob(["src/main/resources/**"]),
deps = ["com.fasterxml.jackson.core:jackson-core:2.8.8"],
main_class = "com.hello.sample.Foo"
)
Upvotes: 0
Views: 552
Reputation: 13553
Have you tried using maven_jar()
directly?
In WORKSPACE:
maven_jar(
name = "com_google_guava_guava",
artifact = "com.google.guava:guava:18.0",
sha1 = "cce0823396aa693798f8882e64213b1772032b09",
)
In BUILD:
java_binary(
name = "HelloWorld",
srcs = glob(["src/main/java/**/*.java"]),
resources = glob(["src/main/resources/**"]),
deps = ["@com_google_guava_guava//jar"],
main_class = "com.hello.sample.Foo"
)
See https://docs.bazel.build/versions/master/be/workspace.html#maven_jar
Upvotes: 1