Run tests with Java 8 without rebuilding all dependencies with Java 8

98 views
Skip to first unread message

Christopher Kilian

unread,
Aug 24, 2022, 10:42:11 AM8/24/22
to bazel-discuss
Hello!

We currently build our codebase with a Java 11 toolchain but use the Jaebel plugin to make the byte code compatible with Java 8. We have a few test classes that need to run with Java 8 due to incompatibilities with Java 11.

I am aware that we can set a config setting in bazelrc to build with Java 8, but this will cause all dependencies of the target to be rebuilt with Java 8 as well. We want to build everything with Java 11 but just have the test run Java 8 at runtime.

scala_rules made this very easy by providing the runtime_jdk (https://github.com/bazelbuild/rules_scala/blob/94fdc8183caf8f6ae49e33bf06a0bc13fef181e3/scala/private/rules/scala_junit_test.bzl#L76) field as an input to the scala_junit_test rule. There doesn't seem to be an equivalent in the java_test rule, but I'm hoping it might be possible to recreate something similar.

java_test has the launcher field which seems like it may be applicable, but I am having trouble finding any documentation or examples on how to create a launcher. This would also not be an optimal way for us to do this, as the launcher must be a cc_binary and we have no other C++ code in our codebase. If this is the only option, could someone point me in the direction of how to create one?

Thank you!

Chris

Christopher Kilian

unread,
Sep 13, 2022, 9:38:30 AM9/13/22
to bazel-discuss
Bumping this

Christopher Kilian

unread,
Sep 21, 2022, 8:01:14 PM9/21/22
to bazel-discuss
Another bump. We're exploring the idea of extending the BazelTestRunner class and passing it as the "main_class" parameter. Interested in other ideas.

Xudong Yang

unread,
Sep 22, 2022, 11:17:08 AM9/22/22
to Christopher Kilian, bazel-discuss, Ivo Ristovski List, h...@google.com
cc Ivo & Hemanshu


--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f0bfcdfc-2d84-4cba-a8f5-6b55f2848a66n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages