diff --git a/MODULE.bazel b/MODULE.bazel index 71e3e577..fe1acd92 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -5,13 +5,13 @@ module( version = "0.10.3", ) -JAVA_VERSION = "20" +JAVA_VERSION = "17" PYTHON_VERSION = "3.11" NODE_VERSION = "20.5.0" -GRAALVM_VERSION = "20.0.2" +GRAALVM_VERSION = "17.0.8" GRAALVM_DIST = "ce" diff --git a/docs/modern-bazel.md b/docs/modern-bazel.md index f756c3b7..57580c9b 100644 --- a/docs/modern-bazel.md +++ b/docs/modern-bazel.md @@ -56,6 +56,7 @@ See the [toolchains guide](./toolchain.md) for more information. | GraalVM version | Bazel version | `rules_graalvm` | Native Image | Components | Windows | Java Toolchains | Hermetic | Notes | | ------------------- | ------------- | ----------------- | ------------ | ---------- | ------- | --------------- | -------- | ------------------------------------- | +| `17.0.7+`/`21+` | Bazel 7 LTS | `0.11.0+` | ✅ | ✅ | ✅ | ✅ | ✅ | Use this doc | | `17.0.7+`/`20.0.1+` | Bazel 7+ | `0.10.0+` | ✅ | ✅ | ✅ | ✅ | ✅ | Use this doc | | `17.0.7+`/`20.0.1+` | Bazel 7+ | `0.9.0` | ✅ | ⚠️ | ⚠️ | ✅ | ✅ | Use this doc | | `17.0.7+`/`20.0.1+` | Bazel 6.x | `0.10.0+` | ✅ | ✅ | ✅ | ✅ | ✅ | Use this doc | @@ -64,4 +65,20 @@ See the [toolchains guide](./toolchain.md) for more information. | `19.0.0`-`22.3.2` | Bazel 4+ | `0.10.0` | ✅ | ✅ | ✖️ | ✅ | ✖️ | See [legacy Bazel](./legacy-bazel.md) | | `19.0.0`-`22.3.2` | Bazel 3.x | [Legacy rules][1] | ✅ | ✖️ | ✖️ | ✖️ | ✖️ | Use [`rules_graal`][1] | +## Java Rules Compatibility + +When using `rules_graalvm`, your `rules_java` version must be modern enough for your selected version of Bazel. If you experience +errors related to `rules_java`, or Java toolchains, it's worth trying a version from the table below. + +| GraalVM version | Bazel version | `rules_graalvm` | `rules_java` | Notes | +| ------------------- | ------------- | ----------------- | ------------ | ----------------------------------------------------------------------------- | +| `17.0.7+`/`21+` | Bazel 7 LTS | `0.11.0+` | `7.1.0+` | Supports JVM21, **no support** for JVM20 (use JVM17 until JVM21 is supported) | +| `17.0.7+`/`20.0.1+` | Bazel 7+ | `0.9.0+` | `6.4.0` | | +| `17.0.7+`/`20.0.1+` | Bazel 6.x | `0.10.0+` | `^6.0.0` | | +| `17.0.7+`/`20.0.1+` | Bazel 5.x | `0.10.0+` | `^5.0.0` | | +| `17.0.7+`/`20.0.1+` | Bazel 4.x | `0.10.0+` | `^4.0.0` | | +| `19.0.0`-`22.3.2` | Bazel 3.x | [Legacy rules][1] | ? | | + +If you still can't get things working, file an issue and we can help. + [1]: https://github.com/andyscott/rules_graal diff --git a/example/integration_tests/components-ce/.bazelrc b/example/integration_tests/components-ce/.bazelrc index f60c08aa..83ebe821 100644 --- a/example/integration_tests/components-ce/.bazelrc +++ b/example/integration_tests/components-ce/.bazelrc @@ -1,3 +1,8 @@ build --enable_bzlmod -build --java_runtime_version=graalvm_20 -build --tool_java_runtime_version=graalvm_20 +build --tool_java_language_version=17 +build --java_runtime_version=graalvm_17 +build --java_language_version=17 +build --tool_java_runtime_version=graalvm_17 +build --extra_toolchains=@graalvm//:toolchain +build --extra_toolchains=@graalvm//:toolchain_gvm +build --extra_toolchains=@graalvm//:bootstrap_runtime_toolchain diff --git a/example/integration_tests/components-ce/MODULE.bazel b/example/integration_tests/components-ce/MODULE.bazel index 7428d04d..f3c1ff94 100644 --- a/example/integration_tests/components-ce/MODULE.bazel +++ b/example/integration_tests/components-ce/MODULE.bazel @@ -26,14 +26,12 @@ gvm.graalvm( "wasm", ], distribution = "ce", - java_version = "20", - version = "20.0.2", + java_version = "17", + version = "17.0.8", ) use_repo( gvm, "graalvm", ) -register_toolchains("@graalvm//:jvm") - register_toolchains("@graalvm//:sdk") diff --git a/example/integration_tests/java-toolchain/.bazelrc b/example/integration_tests/java-toolchain/.bazelrc index cf85b91d..049ce4ba 100644 --- a/example/integration_tests/java-toolchain/.bazelrc +++ b/example/integration_tests/java-toolchain/.bazelrc @@ -1,2 +1,8 @@ -build --java_runtime_version=graalvm_20 -build --tool_java_runtime_version=graalvm_20 +build --extra_toolchains=@graalvm//:toolchain +build --extra_toolchains=@graalvm//:toolchain_gvm +build --extra_toolchains=@graalvm//:bootstrap_runtime_toolchain + +build --tool_java_language_version=17 +build --tool_java_runtime_version=graalvm_17 +build --java_language_version=17 +build --java_runtime_version=graalvm_17 diff --git a/example/integration_tests/java-toolchain/MODULE.bazel b/example/integration_tests/java-toolchain/MODULE.bazel new file mode 100644 index 00000000..00bb1836 --- /dev/null +++ b/example/integration_tests/java-toolchain/MODULE.bazel @@ -0,0 +1,6 @@ +############################################################################### +# Bazel now uses Bzlmod by default to manage external dependencies. +# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. +# +# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 +############################################################################### diff --git a/example/integration_tests/java-toolchain/WORKSPACE.bazel b/example/integration_tests/java-toolchain/WORKSPACE.bazel index e26e1b1f..959132dd 100644 --- a/example/integration_tests/java-toolchain/WORKSPACE.bazel +++ b/example/integration_tests/java-toolchain/WORKSPACE.bazel @@ -9,13 +9,13 @@ load("@rules_graalvm//graalvm:workspace.bzl", "register_graalvm_toolchains", "ru rules_graalvm_repositories() -register_graalvm_toolchains(register_gvm_toolchain = False) +register_graalvm_toolchains() load("@rules_graalvm//graalvm:repositories.bzl", "graalvm_repository") graalvm_repository( name = "graalvm", distribution = "ce", - java_version = "20", - version = "20.0.2", + java_version = "17", + version = "17.0.8", ) diff --git a/tools/bazel/java.bazelrc b/tools/bazel/java.bazelrc index 44b3a73f..6d29d9b8 100644 --- a/tools/bazel/java.bazelrc +++ b/tools/bazel/java.bazelrc @@ -6,6 +6,11 @@ test --test_output=errors build --sandbox_tmpfs_path=/tmp -build --java_language_version=20 -build --java_runtime_version=graalvm_20 build --extra_toolchains=@graalvm//:toolchain +build --extra_toolchains=@graalvm//:toolchain_gvm +build --extra_toolchains=@graalvm//:bootstrap_runtime_toolchain + +build --tool_java_language_version=17 +build --tool_java_runtime_version=graalvm_17 +build --java_language_version=17 +build --java_runtime_version=graalvm_17