Closed guyshefner closed 7 years ago
Thanks @guyshefner, looking into it. Here's the workaround. First note that the generated BUILD
file for any maven_jar
actually contains two rules:
$ less ./bazel-rules_kotlin/external/com_google_guava_guava_21_0/jar/BUILD.bazel
# DO NOT EDIT: automatically generated BUILD.bazel file for maven_jar rule com_google_guava_guava_21_0
java_import(
name = 'jar',
jars = ['guava-21.0.jar'],
visibility = ['//visibility:public']
)
filegroup(
name = 'file',
srcs = ['guava-21.0.jar'],
visibility = ['//visibility:public']
)
Apologies if you knew that already, took me a long time until I realized it. Thus, you can always get at the jar file using the filegroup target rule. Therefore, this can be fed into the jars
attribute of a kotlin_binary rule. So, the following compiles:
kotlin_binary(
name = "main_kt",
main_class = "examples.helloworld.MainKt",
srcs = ["main.kt"],
deps = [":rules"],
java_deps = [":milk", ":guava"],
jars = [
"@com_google_guava_guava_21_0//jar:file",
],
)
Still awkward however as it requires the end-user of rules_kotlin
to have to differentiate this.
Pushed a new version that implements the java_deps
attribute more robustly than the previous hackery, tagged as v0.2.2.
https://github.com/pubref/rules_kotlin/commit/8de6f191de3a59f22886237150bcf7b9dd6c04f1
Hi, thanks for adding the
java_deps
attribute! It's working for the straightforward case of ajava_library
built from java sources, but doesn't seem to be working for the case of ajava_library
which exports other jars.Here are steps to reproduce using
examples/helloworld
:WORKSPACE
file:examples/helloworld/BUILD
:BUILD
file, just to show it working for java rules, add":guava"
to thedeps
attribute of thejava_binary
named"main_java"
, like so:Main.java
:BUILD
file, add":guava"
to thejava_deps
attribute of thekotlin_binary
named"main_kt"
, like so:main.kt
:The failure is:
The same problem happens with the
kotlin_library
rule. I'm using bazel 0.4.5, and rules_kotlin cloned at 522a1e700c0d05610f9dda6c4a40e3ecb4413f68.