public ProjectDescriptor load(@NotNull MessageHandler msgHandler, @NotNull File dataStorageRoot, @NotNull BuildFSState fsState) throws IOException {
    final JpsModel jpsModel = myModelLoader.loadModel();
    BuildDataPaths dataPaths = new BuildDataPathsImpl(dataStorageRoot);
    BuildTargetRegistryImpl targetRegistry = new BuildTargetRegistryImpl(jpsModel);
    ModuleExcludeIndex index = new ModuleExcludeIndexImpl(jpsModel);
    IgnoredFileIndexImpl ignoredFileIndex = new IgnoredFileIndexImpl(jpsModel);
    BuildRootIndexImpl buildRootIndex = new BuildRootIndexImpl(targetRegistry, jpsModel, index, dataPaths, ignoredFileIndex);
    BuildTargetIndexImpl targetIndex = new BuildTargetIndexImpl(targetRegistry, buildRootIndex);
    BuildTargetsState targetsState = new BuildTargetsState(dataPaths, jpsModel, buildRootIndex);

    PathRelativizerService relativizer = new PathRelativizerService(jpsModel.getProject(), isCompilerReferenceFSCaseSensitive());

    ProjectStamps projectStamps = null;
    BuildDataManager dataManager = null;
    try {
      projectStamps = new ProjectStamps(dataStorageRoot, targetsState, relativizer);
      dataManager = new BuildDataManager(dataPaths, targetsState, relativizer);
      if (dataManager.versionDiffers()) {
        myForceCleanCaches = true;
        msgHandler.processMessage(new CompilerMessage(getRootCompilerName(), BuildMessage.Kind.INFO,
                                                      JpsBuildBundle.message("build.message.dependency.data.format.has.changed.project.rebuild.required")));
      }
    }
    catch (Exception e) {
      // second try
      LOG.info(e);
      if (projectStamps != null) {
        projectStamps.close();
      }
      if (dataManager != null) {
        dataManager.close();
      }
      myForceCleanCaches = true;
      NioFiles.deleteRecursively(dataStorageRoot.toPath());
      targetsState = new BuildTargetsState(dataPaths, jpsModel, buildRootIndex);
      projectStamps = new ProjectStamps(dataStorageRoot, targetsState, relativizer);
      dataManager = new BuildDataManager(dataPaths, targetsState, relativizer);
      // second attempt succeeded
      msgHandler.processMessage(new CompilerMessage(getRootCompilerName(), BuildMessage.Kind.INFO,
                                                    JpsBuildBundle.message("build.message.project.rebuild.forced.0", e.getMessage())));
    }

    return new ProjectDescriptor(
      jpsModel, fsState, projectStamps, dataManager, BuildLoggingManager.DEFAULT, index, targetIndex, buildRootIndex, ignoredFileIndex
    );
  }
public ProjectDescriptor load(@NotNull MessageHandler msgHandler, @NotNull File dataStorageRoot, @NotNull BuildFSState fsState)