'How can I stop bazel from creating an entire copy of my project's source files?

I have a simple Java project in a directory called java-fun. Bazel is installed and runs correctly. But whenever it runs, it generates a directory called bazel-java-fun that contains copies of all the src/.../*.java files from my root directory java-fun.

Now my IDE displays a conflicting class name error: Duplicate class found in the file '/Users/traviscramer/java-fun/bazel-java-fun/src/main/Main.java' for every single Java class.

Is there a way to configure bazel so that it doesn't create this bazel-<project name> directory in my workspace?



Solution 1:[1]

Create a .bazelrc in your WORKSPACE.

Add to .bazelrc:

build --symlink_prefix=/ # Out of source build

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vertexwahn