IntelliJ plugin resets the sources root every time I sync

823 views
Skip to first unread message

bri...@gmail.com

unread,
Nov 6, 2017, 6:18:28 PM11/6/17
to bazel-discuss
Hi,

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!

jvo...@gmail.com

unread,
Nov 7, 2017, 6:11:06 PM11/7/17
to bazel-discuss

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.

bri...@gmail.com

unread,
Nov 10, 2017, 5:02:22 PM11/10/17
to bazel-discuss
Thanks for the reply! I have tried this configuration:

directories:
src

But I’m still running into an issue. When I sync, it correctly sets “src” as the source root, but it sets the package prefix to be “src” when it should really be empty. As a result, IntelliJ complains that the package declarations in my Java files are incorrect, because it thinks that they should have “src.” at the beginning of the package name. Do you know why this is happening?

bri...@gmail.com

unread,
Nov 10, 2017, 6:51:06 PM11/10/17
to bazel-discuss
On Tuesday, November 7, 2017 at 3:11:06 PM UTC-8, jvo...@gmail.com wrote:

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

Reply all
Reply to author
Forward
0 new messages