Some GraalVM distributions make available components, which include language implementations, tooling, and other utilities. Your project may need one or more GraalVM components installed in order to build or run correctly.
Using these rules, you can declare your required components in the graalvm_repository
rule, and they will be installed using the GraalVM Updater tool (gu
).
By default, no components are installed beyond what is present in a given distribution. Newer versions of GraalVM distribute the native-image
tool and js
runtime in the base distribution.
In your WORKSPACE.bazel
:
load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")
# ...
graalvm_repository(
name = "graalvm",
version = "20.0.1",
distribution = "oracle",
java_version = "20",
# This is how you install components
components = [
"wasm",
"js",
],
)
This snippet assumes you’ve set up the rules.
[!IMPORTANT]
If you declarecomponents
, make sure to declare the full set you need, including any that may be installed in the base distribution.
For components which ship with GraalVM, component dependencies are managed on behalf of the developer. For example, installing the js
component will automatically install the icu4j
and regex
components, which the js
component depends on.
For components which are not recognized, the rules fall back to calling gu
directly.
With certain GraalVM components or project configurations, you may need to run post-installation actions with the GraalVM Updater tool (gu
):
In your WORKSPACE.bazel
:
load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository")
# ...
graalvm_repository(
name = "graalvm",
version = "20.0.1",
distribution = "oracle",
java_version = "20",
components = [
"espresso",
],
setup_actions = [
"gu rebuild-images libpolyglot -cp $(location @graalvm//:lib/graalvm/lib-javavm.jar)",
],
)