-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
java_plugin can't depend on android_library #2517
Comments
deps of a java_plugin. Also fix the return type of AndroidMapKeyValidator#process, which was depending on an unreleased version of auto-common. [0]: bazelbuild/bazel#2517 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=147052219
So I think that |
I think that the ideal solution here is to expose android.jar to the java rules. This is a little hairy, because android.jar from the Android SDK doesn't really do much, all the methods throw RuntimeExceptions. Dagger's use case seems to only need some constants, which are present in android.jar. The best current solution is probably using a @ahumesky Do you have any thoughts? |
Yes I think a One solution to this is to create
and then create an import that selects the right jar:
then However, there is a shortcut, which is to depend on
Foo.java:
I think that |
deps of a java_plugin. Also fix the return type of AndroidMapKeyValidator#process, which was depending on an unreleased version of auto-common. [0]: bazelbuild/bazel#2517 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=147052219
deps of a java_plugin. Also fix the return type of AndroidMapKeyValidator#process, which was depending on an unreleased version of auto-common. [0]: bazelbuild/bazel#2517 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=147052219
The issue is not that I want a |
Oh I see, I misunderstood. I'm not sure how the Bazel team feels about java rules depending on android rules. The only reason this works internally is because the robolectric test rule is considered a java rule and all the java rules share a common list of allowed dep rules. I suspect if that were redesigned, that would no longer be the case. IMO, the best way to do this is to explicitly reference the libname.jar output of android_library. That was it is explicit that you only want the classes and do not want any assets, manifests, etc. If the java_import is too verbose, you can also put the jar's directly in the deps of the java_library. E.g.
The Bazel team has talked about allowing rules to depend on each other via declared providers, which may someday happen and would solve this case. |
Sounds like you should take a look at #970
It's a work in progress and currently it's a rule by rule work but I guess
you have some pull on the priorities ;)
…On Tue, Feb 14, 2017 at 5:35 PM Adam Michael ***@***.***> wrote:
Oh I see, I misunderstood. I'm not sure how the Bazel team feels about
java rules depending on android rules. The only reason this works
internally is because the robolectric test rule is considered a java rule
and all the java rules share a common list of allowed dep rules. I suspect
if that were redesigned, that would no longer be the case.
IMO, the best way to do this is to explicitly reference the libname.jar
output of android_library. That was it is explicit that you only want the
classes and do not want any assets, manifests, etc. If the java_import is
too verbose, you can also put the jar's directly in the deps of the
java_library. E.g.
java_library(
name = "processor",
srcs = glob(["*.java"]),
deps = [
"//java/dagger/android:libandroid.jar",
"//java/dagger/android/support:libsupport.jar",
...
],
)
The Bazel team has talked about allowing rules to depend on each other via
declared providers, which may someday happen and would solve this case.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2517 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF7wYsYPhZ_1CXGn9nA1wvFv0UQitks5rccnFgaJpZM4L8UhW>
.
|
I would say that right thing to do would be to put the annotations in their own |
That is all true, as well as the fact that the Annotations referenced android types (e.g. |
…l artifact. Due mainly to BasicAnnotationProcessor.ProcessingStep, the dagger-android-processor required a dependency on the dagger-android annotation classes. However, due to restrictions on java_plugin depending on an android_library, mentioned in bazelbuild/bazel#2517, we had to create a java_import to work around this issue. However, soon even the java_import workaround will no longer work. This CL fixes the above issues by switching to the new BasicAnnotaitonProcessor.Step, which allows processing annotations via String instead of Class, which allows us to remove the processors dependency on the dagger-android API altogether. RELNOTES=the Dagger artifact, "dagger-android-jarimpl", has been removed. This was an internal-only artifact, so its removal shouldn't affect users. PiperOrigin-RevId: 375386035
…l artifact. Due mainly to BasicAnnotationProcessor.ProcessingStep, the dagger-android-processor required a dependency on the dagger-android annotation classes. However, due to restrictions on java_plugin depending on an android_library, mentioned in bazelbuild/bazel#2517, we had to create a java_import to work around this issue. However, soon even the java_import workaround will no longer work. This CL fixes the above issues by switching to the new BasicAnnotaitonProcessor.Step, which allows processing annotations via String instead of Class, which allows us to remove the processors dependency on the dagger-android API altogether. RELNOTES=the Dagger artifact, "dagger-android-jarimpl", has been removed. This was an internal-only artifact, so its removal shouldn't affect users. PiperOrigin-RevId: 375386035
…l artifact. Due mainly to BasicAnnotationProcessor.ProcessingStep, the dagger-android-processor required a dependency on the dagger-android annotation classes. However, due to restrictions on java_plugin depending on an android_library, mentioned in bazelbuild/bazel#2517, we had to create a java_import to work around this issue. However, soon even the java_import workaround will no longer work. This CL fixes the above issues by switching to the new BasicAnnotaitonProcessor.Step, which allows processing annotations via String instead of Class, which allows us to remove the processors dependency on the dagger-android API altogether. RELNOTES=the Dagger artifact, "dagger-android-jarimpl", has been removed. This was an internal-only artifact, so its removal shouldn't affect users. PiperOrigin-RevId: 375962581
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so. |
Please provide the following information. The more we know about your system and use case, the more easily and likely we can help.
Description of the problem / feature request / question:
In Dagger we have an
android_library
and we would like to have an annotation processor (java_plugin
) that validates the usage of the library based on some annotations in theandroid_library
. I wrote ajava_library
to enclose the annotation processor code and then added that to thedeps
of thejava_plugin
, but bazel doesn't seem to like that (though this works internally). If I switch the annotation processor library to anandroid_library
rule, it still complains. Each error is something along the lines of:As an aside, I couldn't find any documentation for what
link_params
orjava_common.provider
are.@aj-michael suggested as an interim hack to have a
java_import(name = "foo", jars = ["//java/dagger/android/processor:libprocessor.jar"])
to avoid this issue, which is working but feels like a hack.If possible, provide a minimal example to reproduce the problem:
Here's the commit that I'd like to push to our repo, but it's failing on travis: google/dagger@303bd11#diff-0afa968a073f33b9f552877b10c01445
Environment info
Operating System:
Linux 14.04
Bazel version (output of
bazel info release
):0.4.4
The text was updated successfully, but these errors were encountered: