@Override
  protected void setupModule(Module module) throws ConfigurationException {
    super.setupModule(module);
    assert rootProjectPath != null;

    VirtualFile buildScriptFile = createAndConfigureBuildScriptFile();

    FileDocumentManager.getInstance().saveAllDocuments();

    // it will be set later in any case, but save is called immediately after project creation, so, to ensure that it will be properly saved as external system module
    ExternalSystemModulePropertyManager modulePropertyManager = ExternalSystemModulePropertyManager.getInstance(module);
    modulePropertyManager.setExternalId(GradleConstants.SYSTEM_ID);
    // set linked project path to be able to map the module with the module data obtained from the import
    modulePropertyManager.setRootProjectPath(PathKt.getSystemIndependentPath(rootProjectPath));
    modulePropertyManager.setLinkedProjectPath(PathKt.getSystemIndependentPath(rootProjectPath));

    Project project = module.getProject();

    GradleSettings settings = GradleSettings.getInstance(project);
    GradleProjectSettings projectSettings = getExternalProjectSettings();

    if (isCreatingNewLinkedProject()) {
      projectSettings.setExternalProjectPath(NioPathUtil.toCanonicalPath(rootProjectPath));
      projectSettings.setDistributionType(gradleDistributionType);
      projectSettings.setGradleHome(gradleHome);
      GradleJvmResolutionUtil.setupGradleJvm(project, projectSettings, gradleVersion);
      GradleJvmValidationUtil.validateJavaHome(project, rootProjectPath, gradleVersion);

      TrustedPaths.getInstance().setProjectPathTrusted(rootProjectPath, true);
      settings.linkProject(projectSettings);
    }
    if (isCreatingNewProject) {
      ExternalProjectsManagerImpl.setupCreatedProject(project);
      project.putUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT, Boolean.TRUE);
      // Needed to ignore postponed project refresh
      project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
    }

    // execute when current dialog is closed
    ApplicationManager.getApplication().invokeLater(() -> {
      if (isCreatingBuildScriptFile) {
        preImportConfigurators.forEach(c -> c.accept(buildScriptFile, settingsScriptFile));
        openBuildScriptFile(project, buildScriptFile);
      }
      if (isCreatingNewLinkedProject() && gradleDistributionType.isWrapped()) {
        generateGradleWrapper(project);
      }
      reloadProject(project);
    }, ModalityState.nonModal(), project.getDisposed());
  }
@Override
  protected void setupModule(Module module)