bazel icon indicating copy to clipboard operation
bazel copied to clipboard

java_runtime should allow jvm_opts

Open illicitonion opened this issue 4 years ago • 5 comments

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

illicitonion avatar Apr 06 '21 15:04 illicitonion

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.

cushon avatar Apr 07 '21 06:04 cushon

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.

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).

illicitonion avatar Apr 09 '21 12:04 illicitonion

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

somethingvague avatar Apr 06 '23 09:04 somethingvague

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.

github-actions[bot] avatar Jun 10 '24 01:06 github-actions[bot]

not stale

peakschris avatar Jun 21 '24 11:06 peakschris