-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Technically I did get this to work, but it seems awkward, and so I am probably using jsinterop-generator or bazel wrong, or both.
I have a new git repo of a bazel project using jsinterop-generator to turn some closure-compiler provided externs into jsinterop Java. As with any set of externs I can imagine, this depends on some elemental2 content - both core and dom - so I wrote the jsinterop_generator target like this:
jsinterop_generator(
name = "googlemaps",
srcs = [":google_maps_api_patched.js"],
extension_type_prefix = "Maps",
integer_entities_files = ["integer_entities.txt"],
# override auto generated js_deps in order not to provide extern files
# Common extern file are included by default.
j2cl_js_deps = [],
deps = [
"//third_party:elemental2-core",
"//third_party:elemental2-dom",
],
)
In keeping with bazel conventions, I created an alias for elemental2-core and dom in third_party/, which reference the targets that elemental2 provides:
alias(
name = "elemental2-core",
actual = "@com_google_elemental2//:elemental2-core",
)
alias(
name = "elemental2-dom",
actual = "@com_google_elemental2//:elemental2-dom",
)
This however was not sufficient. In addition to those two targets, these four are also required in that same BUILD file, and would generally be emitted automatically a jsinterop_generator invocation.
alias(
name = "elemental2-core-j2cl",
actual = "@com_google_elemental2//:elemental2-core-j2cl",
)
alias(
name = "elemental2-dom-j2cl",
actual = "@com_google_elemental2//:elemental2-dom-j2cl",
)
alias(
name = "elemental2-core__internal_src_generated",
actual = "@com_google_elemental2//:elemental2-core__internal_src_generated",
)
alias(
name = "elemental2-dom__internal_src_generated",
actual = "@com_google_elemental2//:elemental2-dom__internal_src_generated",
)
The only other thought I had to make these work cleanly was to avoid alias() and instead use jsinterop_generator() in third party:
jsinterop_generator(
name = "elemental2-core",
exports = ["@com_google_elemental2//:elemental2-core"],
)
jsinterop_generator(
name = "elemental2-dom",
exports = ["@com_google_elemental2//:elemental2-dom"],
)
But that seems a bit silly, and doesn't appear to work (jsinterop_generator perhaps is concating labels assuming that targets are local?):
ERROR: /home/colin/workspace/gwt-googlemaps-api/third_party/BUILD:19:1: //third_party:elemental2-core__internal_src_generated: invalid label '//third_party/@com_google_elemental2//:elemental2-core__internal_src_generated' in element 0 of attribute 'exports' in '_jsinterop_generator_export' rule: invalid package name 'third_party/@com_google_elemental2//': package names may not end with '/'
ERROR: /home/colin/workspace/gwt-googlemaps-api/third_party/BUILD:19:1: //third_party:elemental2-core-j2cl: invalid label '//third_party/@com_google_elemental2//:elemental2-core-j2cl' in element 0 of attribute 'exports' in 'j2cl_library' rule: invalid package name 'third_party/@com_google_elemental2//': package names may not end with '/'
ERROR: /home/colin/workspace/gwt-googlemaps-api/third_party/BUILD:19:1: //third_party:elemental2-core: invalid label '//third_party/@com_google_elemental2//:elemental2-core' in element 0 of attribute 'exports' in 'java_library' rule: invalid package name 'third_party/@com_google_elemental2//': package names may not end with '/'
ERROR: /home/colin/workspace/gwt-googlemaps-api/third_party/BUILD:23:1: //third_party:elemental2-dom__internal_src_generated: invalid label '//third_party/@com_google_elemental2//:elemental2-dom__internal_src_generated' in element 0 of attribute 'exports' in '_jsinterop_generator_export' rule: invalid package name 'third_party/@com_google_elemental2//': package names may not end with '/'
ERROR: /home/colin/workspace/gwt-googlemaps-api/third_party/BUILD:23:1: //third_party:elemental2-dom-j2cl: invalid label '//third_party/@com_google_elemental2//:elemental2-dom-j2cl' in element 0 of attribute 'exports' in 'j2cl_library' rule: invalid package name 'third_party/@com_google_elemental2//': package names may not end with '/'
ERROR: /home/colin/workspace/gwt-googlemaps-api/third_party/BUILD:23:1: //third_party:elemental2-dom: invalid label '//third_party/@com_google_elemental2//:elemental2-dom' in element 0 of attribute 'exports' in 'java_library' rule: invalid package name 'third_party/@com_google_elemental2//': package names may not end with '/'
ERROR: error loading package 'third_party': Package 'third_party' contains errors
What is the expected way to invoke jsinterop_generator() in a bazel project, without just forking elemental2 and including its own setup directly in our projects?
Full project is available at https://github.com/Vertispan/gwt-googlemaps-api, but please note that until google/elemental2#137 is resolved, this repo will not build as-is, you need a local_repository of elemental2 with the latest commit reverted.