intellij icon indicating copy to clipboard operation
intellij copied to clipboard

Only manually specified targets are added to Run configurations

Open samolisov opened this issue 6 years ago • 2 comments

I use the Intellij Bazel plugin for Clion and the plugin is built from sources (the HEAD is tag v2019.11.11). In my .bazelproject file, the property derive_targets_from_directories is set to true, but no dynamic derived targets are added to the run configuration (only manually specified in the targets section are).

I've jumped deeply into the plugin code and found in the com.google.idea.blaze.base.run.BlazeRunConfigurationSyncListener class that only targets from the project description are added into the run configurations:

Set<TargetExpression> targetExpressions =
  Sets.newLinkedHashSet(projectViewSet.listItems(TargetSection.KEY));
  // We only auto-generate configurations for rules listed in the project view.
  for (TargetExpression target : targetExpressions) {
    if (!(target instanceof Label) || labelsWithConfigs.contains(target)) {
      continue;
    }
 ...

Actually, I know how to fix it: we can receive an instance of the ProjectTargets class using the SyncProjectTargetHelper helper, in the onSyncComplete listener method we have all required data: project, context, projectViewSet and blazeProjectData that can return us a WorkspacePathResolver and WorkspaceLanguageSettings.

If the maintainers approve, I'll open the PR.

samolisov avatar Nov 14 '19 11:11 samolisov

Any update on this issue? It's very much needed. Imagine working on a big project, it doesn't make sense maintaining a manually created list of targets, instead I would expect that the Bazel Plugin is able to automatically create run configurations for each target same as Clion does for CMake targets. @sgowroji @mai93

alireza-hosseini avatar Dec 08 '22 12:12 alireza-hosseini

Unfortunately, I can't estimate when (or even if) we will be able to work on it. BTW, it doesn't seem like clion-only feature, it would be quite useful for all languages

tpasternak avatar Feb 06 '23 11:02 tpasternak