void (@NotNull ProjectImportAction.AllModels models, @NotNull ProjectResolverContext resolverCtx, boolean useCustomSerialization) { resolverCtx.setModels(models); final Class<? extends ExternalProject> modelClazz = resolverCtx.isPreviewMode() ? ExternalProjectPreview.class : ExternalProject.class; final ExternalProject externalRootProject = models.getModel(modelClazz); if (externalRootProject == null) return; final DefaultExternalProject wrappedExternalRootProject = useCustomSerialization ? (DefaultExternalProject)externalRootProject : new DefaultExternalProject(externalRootProject); models.addModel(wrappedExternalRootProject, ExternalProject.class); final Map<String, DefaultExternalProject> externalProjectsMap = createExternalProjectsMap(wrappedExternalRootProject); Collection<Project> projects = models.getMainBuild().getProjects(); for (Project project : projects) { ExternalProject externalProject = externalProjectsMap.get(project.getProjectIdentifier().getProjectPath()); if (externalProject != null) { models.addModel(externalProject, ExternalProject.class, project); } } for (Build includedBuild : models.getIncludedBuilds()) { final ExternalProject externalIncludedRootProject = models.getModel(includedBuild, modelClazz); if (externalIncludedRootProject == null) continue; final DefaultExternalProject wrappedExternalIncludedRootProject = useCustomSerialization ? (DefaultExternalProject)externalIncludedRootProject : new DefaultExternalProject(externalIncludedRootProject); wrappedExternalRootProject.getChildProjects().put(wrappedExternalIncludedRootProject.getName(), wrappedExternalIncludedRootProject); final Map<String, DefaultExternalProject> externalIncludedProjectsMap = createExternalProjectsMap(wrappedExternalIncludedRootProject); for (ProjectModel project : includedBuild.getProjects()) { ExternalProject externalProject = externalIncludedProjectsMap.get(project.getProjectIdentifier().getProjectPath()); if (externalProject != null) { models.addModel(externalProject, ExternalProject.class, project); } } } }