Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bazel and System Envirentmental Variable

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

Using IntelliJ

Did i get something wrong here?

like image 946
flexxxit Avatar asked Aug 13 '18 08:08

flexxxit


People also ask

Where is Bazelrc?

bazelrc in your workspace directory (next to the main WORKSPACE file). It is not an error if this file does not exist.

Does Bazel work on Windows?

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.

What is a Bazel rule?

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.


1 Answers

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 && '
like image 78
Dane White Avatar answered Sep 19 '22 11:09

Dane White