private Pair<StructuredIdeActivity, List<EventPair<?>>> reportBuildStart(@NotNull ProjectTask projectTask,
                                                                           List<? extends Pair<ProjectTaskRunner, Collection<? extends ProjectTask>>> toRun) {
    Ref<Boolean> incremental = new Ref<>(null);
    AtomicInteger modules = new AtomicInteger(0);
    visitTask(projectTask, tasks -> {
      for (ProjectTask task : tasks) {
        if (task instanceof BuildTask) {
          boolean taskIncremental = ((BuildTask) task).isIncrementalBuild();
          // if any of the tasks is full rebuild, assume everything is full rebuild
          if (!taskIncremental) {
            incremental.set(false);
          }
          else if (incremental.get() == null) {
            incremental.set(true);
          }
        }

        if (task instanceof ModuleBuildTask) {
          modules.incrementAndGet();
        }
      }
    });

    List<EventPair<?>> fields = new SmartList<>();
    fields.add(TASK_RUNNER.with(map(toRun, it -> it.first.getClass())));
    if (incremental.get() != null) {
      fields.add(INCREMENTAL.with(incremental.get()));
    }
    if (modules.get() > 0) {
      fields.add(MODULES.with(modules.get()));
    }
    Class<?> buildOriginator = BUILD_ORIGINATOR_KEY.get(myProject);
    if (buildOriginator != null) {
      myProject.putUserData(BUILD_ORIGINATOR_KEY, null);
      fields.add(BUILD_ORIGINATOR.with(buildOriginator));
    }
    return Pair.create(BUILD_ACTIVITY.started(myProject, () -> fields), fields);
  }
private Pair<StructuredIdeActivity, List<EventPair<?>>> reportBuildStart(@NotNull ProjectTask projectTask,
                                                                           List<? extends Pair<ProjectTaskRunner, Collection<? extends ProjectTask>>> toRun)