Skip to content
Snippets Groups Projects
user avatar
hvadehra authored
* Add version to JavaRuntimeInfo.

1. As suggested in https://github.com/bazelbuild/bazel/issues/6354#issuecomment-1310489402, add a JDK version attribute to the java_runtime rule. This will allow changing behavior based on the Java runtime's version.

2. As an application of the above, pass -Djava.security.manager=allow to Java tests on JDK 17+. This makes the Bazel Java test runner to work on JDK 19. Fixes https://github.com/bazelbuild/bazel/issues/14502.

3. To make the above generally useful, the remote_java_repository and local_java_repository must set the new version attribute in the java_runtime rules that they create. This means the old static jdk.BUILD file no longer suffices. Move the contents of jdk.BUILD into a Starlark file, so the version can be interpolated in by JDK repository rules and macros. (This isn't the nicest, but local_java_repository is not a repository rule, so the template cannot be in a non-Starlark file.)

Closes #17775.

PiperOrigin-RevId: 518860040
Change-Id: I8223b6407dd09528a4e5a6bf12354e5fc68278c6

(cherry picked from commit 7556e110

)

* Use string.replace() instead of string.format() to avoid issues with select{} in the template string

* Remove test and fix formatting

* Fix starlark_repository_test

Change the grep pattern to exactly match what the test is looking for. The old pattern would match BUILD file content from the jdk_build_file.bzl template

---------

Co-authored-by: default avatarBenjamin Peterson <benjamin@engflow.com>
2d04c913
Name Last commit Last update