Skip to content

Commit

Permalink
fix: select jvm17 for dev against bazel 7 lts
Browse files Browse the repository at this point in the history
- fix: select jvm17, `rules_java` doesn't support v20 anymore
- docs: add note about `rules_java` compat

Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Jan 2, 2024
1 parent df34548 commit 73fb16d
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 15 deletions.
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
17 changes: 17 additions & 0 deletions docs/modern-bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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
9 changes: 7 additions & 2 deletions example/integration_tests/components-ce/.bazelrc
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions example/integration_tests/components-ce/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
10 changes: 8 additions & 2 deletions example/integration_tests/java-toolchain/.bazelrc
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions example/integration_tests/java-toolchain/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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
###############################################################################
6 changes: 3 additions & 3 deletions example/integration_tests/java-toolchain/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
9 changes: 7 additions & 2 deletions tools/bazel/java.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 73fb16d

Please sign in to comment.