private static void generateBuildConfiguration(boolean force, @NotNull Project project) {
    MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(project);
    if (!mavenProjectsManager.isMavenizedProject()) {
      return;
    }

    final BuildManager buildManager = BuildManager.getInstance();
    File projectSystemIoFile = buildManager.getProjectSystemDirectory(project);

    final Path projectSystemDir = projectSystemIoFile.toPath();
    RemotePathTransformerFactory.Transformer transformer = RemotePathTransformerFactory.createForProject(project);
    final Path mavenConfigFile = projectSystemDir.resolve(MavenProjectConfiguration.CONFIGURATION_FILE_RELATIVE_PATH);

    ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
    ProjectFileIndex fileIndex = projectRootManager.getFileIndex();

    final int projectRootModificationCount = (int)projectRootManager.getModificationCount();
    final int mavenConfigCrc = mavenProjectsManager.getFilterConfigCrc(fileIndex);
    final int crc = mavenConfigCrc + projectRootModificationCount;

    final Path crcFile = mavenConfigFile.resolveSibling("configuration.crc");

    if (!force) {
      try (DataInputStream crcInput = new DataInputStream(Files.newInputStream(crcFile, StandardOpenOption.READ))) {
        final int lastCrc = crcInput.readInt();
        if (lastCrc == crc) return; // Project had not changed since last config generation.

        LOG.debug(String.format(
          "project configuration changed: lastCrc = %d, currentCrc = %d, projectRootModificationCount = %d, mavenConfigCrc = %d",
          lastCrc, crc, projectRootModificationCount, mavenConfigCrc));
      }
      catch (IOException e) {
        LOG.debug("Unable to read or find config file: " + e.getMessage());
      }
    }

    MavenProjectConfiguration projectConfig = new MavenProjectConfiguration();
    for (MavenProject mavenProject : mavenProjectsManager.getProjects()) {
      new ResourceConfigGenerator(fileIndex, mavenProjectsManager, transformer, projectConfig, mavenProject).generateResourceConfig();
    }
    addNonMavenResources(transformer, projectConfig, mavenProjectsManager, project);

    final Element element = new Element("maven-project-configuration");
    XmlSerializer.serializeInto(projectConfig, element);
    buildManager.runCommand(() -> {
      if (!project.isDefault()) {
        buildManager.clearState(project);
      }
      try {
        JDOMUtil.write(element, mavenConfigFile);
        try (DataOutputStream crcOutput = new DataOutputStream(
          new BufferedOutputStream(Files.newOutputStream(crcFile, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE)))) {
          crcOutput.writeInt(crc);
        }
      }
      catch (IOException e) {
        LOG.debug("Unable to write config file", e);
        throw new RuntimeException(e);
      }
    });
  }
private static void generateBuildConfiguration(boolean force, @NotNull Project project)