bazel
bazel copied to clipboard
java_runtime should allow jvm_opts
Description of the problem / feature request:
Sometimes you want to set JVM options whenever a JVM is run. An example is wanting to use --enable-preview - if this flag was used when compiling code, it must also be set when running it.
Currently, java_toolchain has a jvm_opts attribute which is used to pass flags to javac. There is currently no way to ensure these options are also passed at test or run time.
Feature requests: what underlying problem are you trying to solve with this feature?
Add jvm_opts to java_runtime, which will be propagated to the JVM for all actions using that JVM (compiles, tests, runs).
/cc @comius
There is currently no way to ensure these options are also passed at test or run time.
Note that there's --jvmopt flag (and as of #11893) a corresponding --host_jvmopt flag that pass JVM flags to tests and binaries.
There is currently no way to ensure these options are also passed at test or run time.
Note that there's
--jvmoptflag (and as of #11893) a corresponding--host_jvmoptflag that pass JVM flags to tests and binaries.
Good point - there is a way - I'd argue that being able to couple "This java_runtime always uses these flags" is still a useful feature, but it's probably lower priority given you can just set --jvmopt in parallel with configuring the java_runtime (as long as you're only using one java_runtime).
We also would like this feature. Our use case is to always configure the runtime to use a custom keystore. The custom keystore is built with Bazel so we cannot use location substitution in .bazelrc
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.
not stale