The jsinterop generator is a java program that takes closure extern files as input and generates
Java classes annotated with JsInterop annotations.
This project is used for building Elemental2.
Any other uses are experimental. You can use it to generate java APIs for other javascript libraries but we don’t provide any official support. Feel free to open issues on the github issue tracker, though.
Run with Bazel
Using Bazel 8 or later, add to your MODULE.bazel file:
bazel_dep(name = "jsinterop_generator", version = "<RELEASE_VERSION>")
Then, in your BUILD file, load the generator rule and use it:
load("@jsinterop_generator//:jsinterop_generator.bzl", "jsinterop_generator")
jsinterop_generator(
name = "my_thirdparty_lib",
srcs = ["my_externs.js"],
)
You can now directly depend on :my_thirdparty_lib target in your java_library rules or build the jar files with bazel build //path/to/your/BUILD/file/directory:my_thirdparty_lib.
The jar files with the generated source will created in bazel-bin/path/to/your/BUILD/file/directory.
JsInterop Generator ·
· 
The jsinterop generator is a java program that takes closure extern files as input and generates Java classes annotated with JsInterop annotations.
Run with Bazel
Using Bazel 8 or later, add to your
MODULE.bazelfile:Replace
RELEASE_VERSIONwith an actual release version.Then, in your
BUILDfile, load the generator rule and use it:You can now directly depend on
:my_thirdparty_libtarget in yourjava_libraryrules or build the jar files withbazel build //path/to/your/BUILD/file/directory:my_thirdparty_lib. The jar files with the generated source will created inbazel-bin/path/to/your/BUILD/file/directory.Run as a standalone java program
Build the generator from source
The generated jar file can be found at
bazel-bin/java/jsinterop/generator/closure/ClosureJsinteropGenerator_deploy.jarRun the generator
Now you have the jar file, just invoke
List of required
options:Contributing
Please refer to the contributing document.
Licensing
Please refer to the license file.
Disclaimer
This is not an official Google product.