use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class JavaModuleSetupTest method testSetUpModuleWithProgressIndicator.
public void testSetUpModuleWithProgressIndicator() {
when(myJavaModuleModel.isAndroidModuleWithoutVariants()).thenReturn(false);
IdeModifiableModelsProvider modelsProvider = mock(IdeModifiableModelsProvider.class);
Module module = getModule();
myModuleSetup.setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, myProgressIndicator);
verify(mySetupStep1, times(1)).setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, myProgressIndicator);
verify(mySetupStep2, times(1)).setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, myProgressIndicator);
verify(mySetupStep1, times(1)).displayDescription(module, myProgressIndicator);
verify(mySetupStep2, times(1)).displayDescription(module, myProgressIndicator);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project intellij-community by JetBrains.
the class AbstractExternalProjectImportBuilder method commit.
@Override
public List<Module> commit(final Project project, final ModifiableModuleModel model, final ModulesProvider modulesProvider, final ModifiableArtifactModel artifactModel) {
project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
final DataNode<ProjectData> externalProjectNode = getExternalProjectNode();
if (externalProjectNode != null) {
beforeCommit(externalProjectNode, project);
}
final boolean isFromUI = model != null;
final List<Module> modules = ContainerUtil.newSmartList();
final IdeModifiableModelsProvider modelsProvider = isFromUI ? new IdeUIModifiableModelsProvider(project, model, (ModulesConfigurator) modulesProvider, artifactModel) {
@NotNull
@Override
public Module newModule(@NotNull @NonNls String filePath, String moduleTypeId) {
final Module module = super.newModule(filePath, moduleTypeId);
modules.add(module);
return module;
}
} : new IdeModifiableModelsProviderImpl(project) {
@NotNull
@Override
public Module newModule(@NotNull @NonNls String filePath, String moduleTypeId) {
final Module module = super.newModule(filePath, moduleTypeId);
modules.add(module);
return module;
}
};
AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, myExternalSystemId);
final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
//noinspection unchecked
Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
// add current importing project settings to linked projects settings or replace if similar already exist
projects.remove(projectSettings);
projects.add(projectSettings);
//noinspection unchecked
systemSettings.copyFrom(myControl.getSystemSettings());
//noinspection unchecked
systemSettings.setLinkedProjectsSettings(projects);
if (externalProjectNode != null) {
if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
ExternalProjectDataSelectorDialog dialog = new ExternalProjectDataSelectorDialog(project, new InternalExternalProjectInfo(myExternalSystemId, projectSettings.getExternalProjectPath(), externalProjectNode));
if (dialog.hasMultipleDataToSelect()) {
dialog.showAndGet();
} else {
Disposer.dispose(dialog.getDisposable());
}
}
if (!project.isInitialized()) {
StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> finishImport(project, externalProjectNode, isFromUI, modules, modelsProvider, projectSettings));
} else
finishImport(project, externalProjectNode, isFromUI, modules, modelsProvider, projectSettings);
}
return modules;
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStepTest method testDoSetUpModuleWithCompiledJar.
public void testDoSetUpModuleWithCompiledJar() throws IOException {
Module module = getModule();
String moduleName = module.getName();
File buildFolderPath = createTempDir("build");
File jarFilePath = new File(buildFolderPath, moduleName + ".jar");
createIfDoesntExist(jarFilePath);
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
Map<String, Set<File>> artifactsByConfiguration = new HashMap<>();
artifactsByConfiguration.put("default", Collections.singleton(jarFilePath));
JavaModuleModel model = new JavaModuleModel(moduleName, Collections.emptyList(), Collections.emptyList(), artifactsByConfiguration, null, buildFolderPath, null, true, false);
mySetupStep.doSetUpModule(module, modelsProvider, model, null, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
Library[] libraries = libraryTable.getLibraries();
assertThat(libraries).isEmpty();
assertAbout(libraryDependencies()).that(module).isEmpty();
// No libraries were created, nothing should be marked as "used".
verify(myLibraryRegistry, never()).markAsUsed(any(), any());
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class JavaLanguageLevelModuleSetupStepTest method testSetUpModuleWithLanguageLevelInJavaProject.
public void testSetUpModuleWithLanguageLevelInJavaProject() {
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
when(myJavaModuleModel.getJavaLanguageLevel()).thenReturn(JDK_1_7);
Module module = getModule();
mySetupStep.setUpModule(module, modelsProvider, myJavaModuleModel, null, null);
// Commit changes to verify results.
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
verifyLanguageLevel(module, JDK_1_7);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class JavaLanguageLevelModuleSetupStepTest method testSetUpModuleWithNoLanguageLevel.
public void testSetUpModuleWithNoLanguageLevel() {
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
when(myJavaModuleModel.getJavaLanguageLevel()).thenReturn(null);
Module module = getModule();
mySetupStep.setUpModule(module, modelsProvider, myJavaModuleModel, null, null);
// Commit changes to verify results.
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
verifyLanguageLevel(module, JDK_1_6);
}
Aggregations