private void deleteOutdatedFiles(MultiMap<String, String> filesToDelete,
                                     SourceToOutputMapping srcOutMapping,
                                     ArtifactOutputToSourceMapping outSrcMapping) throws IOException {
      if (filesToDelete.isEmpty()) return;

      context.processMessage(new ProgressMessage(JpsBuildBundle.message("progress.message.deleting.outdated.files")));
      int notDeletedFilesCount = 0;
      Set<String> notDeletedPaths = CollectionFactory.createFilePathSet();
      Set<String> deletedPaths = CollectionFactory.createFilePathSet();

      for (String filePath : filesToDelete.keySet()) {
        if (notDeletedPaths.contains(filePath)) {
          continue;
        }

        boolean deleted = deletedPaths.contains(filePath);
        if (!deleted) {
          deleted = FileUtil.delete(new File(filePath));
        }

        if (deleted) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Outdated output file deleted: " + filePath);
          }
          outSrcMapping.remove(filePath);
          deletedPaths.add(filePath);
          for (String sourcePath : filesToDelete.get(filePath)) {
            srcOutMapping.removeOutput(sourcePath, filePath);
          }
        }
        else {
          notDeletedPaths.add(filePath);
          if (notDeletedFilesCount++ > 50) {
            context.processMessage(new CompilerMessage(getBuilderName(), BuildMessage.Kind.WARNING,
                                                       JpsBuildBundle.message("build.message.deletion.of.outdated.files.stopped")));
            break;
          }
          context.processMessage(new CompilerMessage(getBuilderName(), BuildMessage.Kind.WARNING,
                                                     JpsBuildBundle.message("build.message.cannot.delete.file.0", filePath)));
        }
      }
      ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
      if (logger.isEnabled()) {
        logger.logDeletedFiles(deletedPaths);
      }
    }
private void deleteOutdatedFiles(MultiMap<String, String> filesToDelete,
                                     SourceToOutputMapping srcOutMapping,
                                     ArtifactOutputToSourceMapping outSrcMapping)