com.intellij.projectImport.ProjectImportProvider Java Examples

The following examples show how to use com.intellij.projectImport.ProjectImportProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GradleToolDelegate.java    From intellij-quarkus with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void processImport(Module module) {
    Project project = module.getProject();
    File gradleFile = null;

    for(VirtualFile virtualFile : ModuleRootManager.getInstance(module).getContentRoots()) {
        File baseDir = VfsUtilCore.virtualToIoFile(virtualFile);
        File file = new File(baseDir, "build.gradle");
        if (file.exists()) {
            gradleFile = file;
            break;
        }
    }

    if (gradleFile != null) {
        ProjectImportProvider gradleProjectImportProvider = getGradleProjectImportProvider();
        ProjectImportBuilder gradleProjectImportBuilder = gradleProjectImportProvider.getBuilder();
        AddModuleWizard wizard = new AddModuleWizard(project, gradleFile.getPath(), new ProjectImportProvider[]{gradleProjectImportProvider});
        if (wizard.getStepCount() == 0 || wizard.showAndGet()) {
            gradleProjectImportBuilder.commit(project, (ModifiableModuleModel)null, (ModulesProvider)null);
        }
    }
}
 
Example #2
Source File: L2GitUtil.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
private void notifyCheckoutListeners(final File directory, final boolean checkoutCompleted) {
    final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(directory);

    final AddModuleWizard wizard = ImportModuleAction.createImportWizard(null, null, file,
            ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions());
    if (wizard == null) return;
    ImportModuleAction.createFromWizard(null, wizard);


    if (!checkoutCompleted) {
        final VcsAwareCheckoutListener[] vcsAwareExtensions = Extensions.getExtensions(VcsAwareCheckoutListener.EP_NAME);
        for (VcsAwareCheckoutListener extension : vcsAwareExtensions) {
            boolean processingCompleted = extension.processCheckedOutDirectory(myProject, directory, myVcsKey);
            if (processingCompleted) break;
        }
    }

    newProject = Objects.requireNonNull(findProjectByBaseDirLocation(directory));
}
 
Example #3
Source File: RoboVmModuleBuilder.java    From robovm-idea with GNU General Public License v2.0 4 votes vote down vote up
private void applyBuildSystem(final Project project) {
    if (buildSystem == BuildSystem.Gradle) {
        File baseDir = VfsUtilCore.virtualToIoFile(project.getBaseDir());
        File[] files = baseDir.listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return FileUtil.namesEqual("build.gradle", name);
            }
        });
        if (files != null && files.length != 0) {
            project.putUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT, Boolean.TRUE);
            ProjectDataManager projectDataManager = (ProjectDataManager) ServiceManager
                    .getService(ProjectDataManager.class);
            GradleProjectImportBuilder gradleProjectImportBuilder = new GradleProjectImportBuilder(
                    projectDataManager);
            gradleProjectImportBuilder.getControl(project).getProjectSettings()
                    .setDistributionType(DistributionType.WRAPPED);
            GradleProjectImportProvider gradleProjectImportProvider = new GradleProjectImportProvider(
                    gradleProjectImportBuilder);
            AddModuleWizard wizard = new AddModuleWizard((Project) null, files[0].getPath(),
                    new ProjectImportProvider[] { gradleProjectImportProvider });
            if (wizard.getStepCount() <= 0 || wizard.showAndGet()) {
                ImportModuleAction.createFromWizard(project, wizard);

                ApplicationManager.getApplication().runWriteAction(new Runnable() {
                    @Override
                    public void run() {
                        ModifiableModuleModel modifiableModel = ModuleManager.getInstance(project).getModifiableModel();
                        for (Module module : modifiableModel.getModules()) {
                            try {
                                LanguageLevelModuleExtensionImpl langModel = (LanguageLevelModuleExtensionImpl) LanguageLevelModuleExtensionImpl.getInstance(module).getModifiableModel(true);
                                langModel.setLanguageLevel(LanguageLevel.JDK_1_8);
                                langModel.commit();
                            } catch(Throwable t) {
                                // could be a non-Java project
                                t.printStackTrace();
                            }
                        }
                        modifiableModel.commit();
                    }
                });
            }
        }
    } else {
        FileDocumentManager.getInstance().saveAllDocuments();
        MavenProjectsManager.getInstance(project).forceUpdateAllProjectsOrFindAllAvailablePomFiles();
    }
}