feat: Add gazelle to plugin
This is a WIP because I can't figure out how to make the tests work.
Checklist
- [X] I have filed an issue about this change and discussed potential changes with the maintainers.
- [X] I have received the approval from the maintainers to make this change.
- [X] This is not a stylistic, refactoring, or cleanup change.
Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See the Contributions section in the README for more details.
Discussion thread for this change
Issue number: 3216
Description of this change
See linked issue for a description and general design. This is a port of the existing plugin: https://github.com/blorente/intellij_gazelle. Refer to that README for usage.
Architecturally, this plugin does two things:
- Implements a
GazelleSyncPlugin, which inserts itself between thebazel infoandbazel buildphases of a sync cycle, to run gazelle in between, via aBlazeGazelleRunnerImpl. - Hooks into UserSettings, to add a global field to specify a gazelle target to run on sync.
Refer to gazelle/src/META-INF/blaze-gazelle.xml for a reference of the extension points to the plugin.
NOTE: The added tests in this PR set up a full repository and run gazelle. This is potentially expensive, in the order of single-digit seconds.
If I'm not mistaken this will run gazelle on a list of preconfigured targets, could potentially take a long time if working on several different projects in a large monorepo. I guess this is in no way blocking since if users don't configure anything, it won't run at all.
Just FYI I've been working on something similar but only run gazelle on a list of paths that contain dependency graph changes, I can open another PR with my changes when they are ready.
I believe this fixes https://github.com/bazelbuild/intellij/issues/3216
@mai93 Thank you so much for your comments, I think the plugin has improved a lot as a result. I've tried to address all of them, if you could take a look at your earliest convenience, it would be great.
@mai93 Thanks for your review! I've addressed the comments and rebased the branch.
Thank you, @blorente! That looks good but the CI tests are failing with a timeout, can you please check that (https://buildkite.com/bazel/intellij-ue-plugin/builds/7314)?
@mai93 Thanks for the review! The issues with the tests was that the UI setup wasn't done properly for testing. Turns out, we should probably not do any UI setup for testing at all, so added a headless mode in the latest commit.
Tests should pass now, please let me know what you think.