-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bazel run doesn't honor --javabase, uses internal Java version #16
Comments
Thanks for reporting, we will look at this. |
I just solved a similar issue for python execution of the dupe class checker script. It was using system python, but I found the way to invoke the python toolchain. I thought the same approach would work for this use case, doing the following: (these comments are references in springboot.bzl)
But the JDK toolchain is not quite there. Fortunately, in the last day it looks like they finally finished the Java toolchain work in Bazel master: So it looks like this issue will be unblocked by the next Bazel release (Dec 2020 or later). |
My previous comment neglected to mention that we are still targeting Bazel 1.2.1 and later for support. We use Bazel 1.2.1 to develop the springboot rule, and that is probably why the java toolchain is not working. Internally we use Bazel 3.x for our builds, and the toolchain is better supported. So we could either:
|
This open issue is mitigated to a degree by this new feature: launcher_script attribute #92 You can now tailor the launcher script as needed in your environment. That still won't automatically pick up java_base but it may be enough. |
Also consider the usage of arg files for bazel run: % javac --help We have some services that expect certain JVM args at startup. We have docs that tell users to include an args file when invoking bazel run (export JAVA_OPTS='@theargsfile') but something automatic is needed. |
rules_spring should honor the Java runtime version specified with the |
I'm using Java 11 and therefore have the following in my .bazelrc:
run --javabase=@bazel_tools//tools/jdk:remote_jdk11
For java_binary rules, this works great, causing them to run with JDK 11. However, when I do a
bazel run
on a springboot target, it always uses Java 1.8. I believe the reason is that it looks at JAVA_HOME, which is not taken from my environment but rather from the environment internal to the bazel server. I confirmed this by modifyingspringboot.bzl
to echo JAVA_HOME. It gave me jdk1.8 even though my JAVA_HOME is pointing to jdk-11.The text was updated successfully, but these errors were encountered: