For the same project, I work both in the Bazel IntelliJ plugin and the command-line.
Whenever I re "Sync Project with BUILD files" from within IntelliJ, or do a new bazel build from the command-line, whichever one I have done last forces the other one to do a full rebuild of my project (with 100s of targets).
For example, if I run a test from within IntelliJ, and then do something from the command line like bazel build //... or even run the same test from the CLI, I get:
$ bazel test //foo:bar
INFO: Build options have changed, discarding analysis cache.
...
which is forcing my project to rebuild Protobuf and other native things that are not quick.
Why is this?
I can see that when IntelliJ invokes a test, for example, it has this full set of arguments to the bazel command, which I never specify any of at the CLI:
/usr/local/bin/bazel test --tool_tag=ijwb:IDEA:ultimate \
--curses=no --color=yes --experimental_ui=no \
--progress_in_terminal_title=no --runs_per_test=1 \
--flaky_test_attempts=1 \
--build_event_binary_file=/var/folders/08/fk59w_xd4zz2phs6q6r3r5mc0000gn/T/intellij-bep-b37bc093-86b4-4a03-9599-a45e7285f6ac \
--nobuild_event_binary_file_path_conversion \
--test_filter=com.spotify.spyglass.knightcrock.CommitInfoParserTest#
-- //knightcrock-consumer:CommitInfoParserTest
What I am experiencing is exactly what is described in https://github.com/bazelbuild/bazel/issues/3433, which was closed without much comment for being opened in the wrong place.