jsinterop-annotations icon indicating copy to clipboard operation
jsinterop-annotations copied to clipboard

Visibility error when added as dep per readme

Open rendaw opened this issue 5 years ago • 2 comments

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.

rendaw avatar Feb 11 '21 12:02 rendaw

@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.

gkdn avatar Feb 11 '21 19:02 gkdn

Okay, and thanks for clarifying!

rendaw avatar Feb 12 '21 01:02 rendaw