private static @NotNull Collection<File> collectSourceSetArtifacts(
    @NotNull Project project,
    @NotNull ModelBuilderContext context,
    @NotNull SourceSet sourceSet
  ) {
    Collection<File> sourceSetArtifacts = new LinkedHashSet<>();
    TaskCollection<AbstractArchiveTask> archiveTaskCollection = project.getTasks().withType(AbstractArchiveTask.class);
    GradleCollectionVisitor.accept(archiveTaskCollection, new GradleCollectionVisitor<AbstractArchiveTask>() {

      @Override
      public void visit(AbstractArchiveTask element) {
        if (containsAllSourceSetOutput(element, sourceSet)) {
          sourceSetArtifacts.add(GradleTaskUtil.getTaskArchiveFile(element));
        }
      }

      @Override
      public void onFailure(AbstractArchiveTask element, @NotNull Exception exception) {
        context.getMessageReporter().createMessage()
          .withGroup(Messages.SOURCE_SET_MODEL_SOURCE_SET_ARTIFACT_GROUP)
          .withTitle("Project configuration error")
          .withText("Cannot resolve an artifact file for the source set " + element)
          .withKind(Message.Kind.WARNING)
          .withException(exception)
          .reportMessage(project);
      }

      @Override
      public void visitAfterAccept(AbstractArchiveTask element) {
        context.getMessageReporter().createMessage()
          .withGroup(Messages.SOURCE_SET_MODEL_SKIPPED_SOURCE_SET_ARTIFACT_GROUP)
          .withTitle("Project configuration error")
          .withText("Artifact files collecting for source sets was finished. " +
                    "Resolution for the source set" + element + " will be skipped.")
          .withInternal().withStackTrace()
          .withKind(Message.Kind.WARNING)
          .reportMessage(project);
      }
    });
    return sourceSetArtifacts;
  }
private static @NotNull Collection<File> collectSourceSetArtifacts(
    @NotNull Project project,
    @NotNull ModelBuilderContext context,
    @NotNull SourceSet sourceSet
  )