google / jsinterop-annotations

JsInterop java annotations for J2CL and GWT
Apache License 2.0
18 stars 8 forks source link

Visibility error when added as dep per readme #3

Open rendaw opened 3 years ago

rendaw commented 3 years ago

I'm new to j2cl and Bazel FWIW.

I was missing the annotations dep and got this error:

error: [strict] Using type jsinterop.annotations.JsType from an indirect dependency (TOOL_INFO: "@com_google_jsinterop_annotations-j2cl//java/jsinterop/annotations"). See command below **
import jsinterop.annotations.JsType;
                            ^
 ** Please add the following dependencies: 
  @com_google_jsinterop_annotations-j2cl//java/jsinterop/annotations to //...
 ** You can use the following buildozer command: 
buildozer 'add deps @com_google_jsinterop_annotations-j2cl//java/jsinterop/annotations' //...

Adding @com_google_jsinterop_annotations-j2cl//java/jsinterop/annotations didn't work:

in deps attribute of j2cl_library rule //...: '@com_google_jsinterop_annotations-j2cl//java/jsinterop/annotations:annotations' does not have mandatory providers: 'closure_js_library'. Since this rule was created by the macro 'j2cl_library', the error might have been caused by the macro implementation

Searching brought me here -- I think this is the same library. The readme says to add @com_google_jsinterop_annotations//:jsinterop-annotations-j2cl to deps, but this produces the error:

in j2cl_library rule //com/zarbosoft/merman:editor: alias '@com_google_jsinterop_annotations//:jsinterop-annotations-j2cl' referring to target '@com_google_jsinterop_annotations//java/jsinterop/annotations:annotations-j2cl' is not visible from target '//...'. Check the visibility declaration of the former target if you think the dependency is legitimate

Eventually I found an example of the annotations in the guava j2cl sample, which uses @com_google_j2cl//:jsinterop-annotations-j2cl and this worked.

I'm not sure if this is the recommended usage though.

gkdn commented 3 years ago

@com_google_jsinterop_annotations is polluted with rules_closure that is bringing in an older version of the library and probably causing your issue.

@com_google_j2cl//:jsinterop-annotations-j2cl should work well for now. I will try to cleanup rules_closure at one point.

rendaw commented 3 years ago

Okay, and thanks for clarifying!