org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider Java Examples
The following examples show how to use
org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider.
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: GradleModuleBuilderPostProcessor.java From intellij-spring-assistant with MIT License | 6 votes |
@Override public boolean postProcess(Module module) { // TODO: Find a way to use GradleModuleBuilder instead of GradleProjectImportBuilder when adding a child module to the parent Project project = module.getProject(); VirtualFile gradleFile = findFileUnderRootInModule(module, "build.gradle"); if (gradleFile == null) { // not a gradle project return true; } else { ProjectDataManager projectDataManager = getService(ProjectDataManager.class); GradleProjectImportBuilder importBuilder = new GradleProjectImportBuilder(projectDataManager); GradleProjectImportProvider importProvider = new GradleProjectImportProvider(importBuilder); AddModuleWizard addModuleWizard = new AddModuleWizard(project, gradleFile.getPath(), importProvider); if (addModuleWizard.getStepCount() > 0 && !addModuleWizard .showAndGet()) { // user has cancelled import project prompt return true; } else { // user chose to import via the gradle import prompt importBuilder.commit(project, null, null); return false; } } }
Example #2
Source File: TalendModuleBuilder.java From component-runtime with Apache License 2.0 | 4 votes |
@Override public Module createModule(final ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, ConfigurationException, JDOMException { final Module module = super.createModule(moduleModel); getApplication().invokeLater(() -> { ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { final ProjectDownloader downloader = new ProjectDownloader(this, request); try { downloader.download(ProgressManager.getInstance().getProgressIndicator()); } catch (IOException e) { getApplication() .invokeLater(() -> MessagesEx .showErrorDialog(e.getMessage(), getMessage("download.project.file.error"))); } }, getMessage("download.project.file"), true, null); final Project moduleProject = module.getProject(); switch (jsonProject.get("buildType").getAsString()) { case "Maven": final VirtualFile pomFile = findFileUnderRootInModule(module, "pom.xml"); if (pomFile != null) { final MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(moduleProject); mavenProjectsManager.addManagedFiles(singletonList(pomFile)); } break; case "Gradle": final VirtualFile gradleFile = findFileUnderRootInModule(module, "build.gradle"); if (gradleFile != null) { final ProjectDataManager projectDataManager = getService(ProjectDataManager.class); // todo: move to JavaGradleProjectImportBuilder final GradleProjectImportBuilder importBuilder = new GradleProjectImportBuilder(projectDataManager); final GradleProjectImportProvider importProvider = new GradleProjectImportProvider(importBuilder); final AddModuleWizard addModuleWizard = new AddModuleWizard(moduleProject, gradleFile.getPath(), importProvider); if (addModuleWizard.getStepCount() == 0 && addModuleWizard.showAndGet()) { // user chose to import via the gradle import prompt importBuilder.commit(moduleProject, null, null); } } break; default: break; } }, ModalityState.current()); return module; }
Example #3
Source File: RoboVmModuleBuilder.java From robovm-idea with GNU General Public License v2.0 | 4 votes |
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(); } }