I am building my java project with bazel. I want to use environmental variable at build/run time. According to the documentation --action_env=APP_ENV=Development
should work.
So i do bazel run myproject:app --action_env=APP_ENV=Development
But System.getenv("APP_ENV");
is null
In my intellij IDE I have the following. Neither --action_env=APP_ENV=Development
nor --action_env APP_ENV=Development
work
Did i get something wrong here?
bazelrc in your workspace directory (next to the main WORKSPACE file). It is not an error if this file does not exist.
On Windows, Bazel builds two output files for java_binary rules: a . jar file. a .exe file that can set up the environment for the JVM and run the binary.
A rule defines a series of actions that Bazel performs on inputs to produce a set of outputs, which are referenced in providers returned by the rule's implementation function.
You can use --run_under
to add a prefix to the Bazel run command. This can be used in the IntelliJ Run/Debug configuration to set environment variables.
--run_under='export VAR1=FOO VAR2=BAR && '
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With