I'm using the IntelliJ Bazel plugin. I am using Java, and I have a "src" directory in the root of my workspace that serves as the root of my Java code. Every time that I sync with my BUILD files, IntelliJ resets it so that my project root is the source root, and I have to manually change it to have "src" be the source root every time. Does anyone know how to prevent this from happening?
Thanks!
What is your "project view"? (https://ij.bazel.build/docs/project-views.html#creating-the-project-view)
The Bazel plugin uses the "directories" specified there to set up the intellij content roots (updated on every sync). If you have something like:
directories:
parent
parent/src
parent/other
# ...
it will just pick the common "parent" as the content root.
Actually, I figured out what the issue was! There seems to be a bug in the way the Bazel plugin calls the bazel command on MacOS. As one of the arguments, it provides a path that includes a directory called "Application Support", but it does not properly escape this, so the Bazel command thinks that there everything starting with "Support" is a separate argument. As a temporary hacky solution, I wrote a Python script to wrap the Bazel command that automatically merges adjacent arguments if one ends with "Application" and the next starts with "Support". If someone on the Bazel team could look into this, I would really appreciate it!
Below is the exact command that the IntelliJ plugin was running. As you can see, the argument to --override_repository is not properly escaped.
bazel build --tool_tag=ijwb:IDEA:ultimate --keep_going --experimental_build_event_binary_file=/var/folders/95/3fmnbpg50_v06gty9hfdqx900000gn/T/intellij-bep-71ac07a3-ead7-4856-bb23-85c415e8153f --noexperimental_build_event_binary_file_path_conversion --curses=no --color=no --noexperimental_ui --noprogress_in_terminal_title --aspects=@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect --override_repository=intellij_aspect=/Users/bricewh/Library/Application Support/IntelliJIdea2017.2/ijwb/aspect --output_groups=intellij-info-java,intellij-info-py,intellij-info-generic -- //...