use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.
the class NdkModuleModelDataServiceTest method testImportData.
public void testImportData() {
myModelsProvider = new IdeModifiableModelsProviderImpl(getProject());
String appModuleName = "app";
Module appModule = createModule(appModuleName);
NdkModuleModel model = mock(NdkModuleModel.class);
when(model.getModuleName()).thenReturn(appModuleName);
DataNode<NdkModuleModel> dataNode = new DataNode<>(NDK_MODEL, model, null);
Collection<DataNode<NdkModuleModel>> dataNodes = Collections.singleton(dataNode);
myDataService.importData(dataNodes, null, getProject(), myModelsProvider);
verify(myModuleSetup).setUpModule(appModule, myModelsProvider, model, null, null);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.
the class AndroidModuleDependenciesSetupTest method testSetUpLibraryWithNewLibrary.
public void testSetUpLibraryWithNewLibrary() throws IOException {
File binaryPath = createTempFile("fakeLibrary", "jar");
File sourcePath = createTempFile("fakeLibrary-src", "jar");
when(myLibraryFilePaths.findSourceJarPath(binaryPath)).thenReturn(sourcePath);
String libraryName = binaryPath.getName();
Module module = getModule();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
File[] binaryPaths = { binaryPath };
myDependenciesSetup.setUpLibraryDependency(module, modelsProvider, libraryName, COMPILE, binaryPath, binaryPaths, EMPTY_FILE_ARRAY);
// Apply changes before checking state.
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
List<LibraryOrderEntry> libraryOrderEntries = getLibraryOrderEntries(module);
// Only one library should be in the library table.
assertThat(libraryOrderEntries).hasSize(1);
Library library = libraryOrderEntries.get(0).getLibrary();
assertNotNull(library);
assertEquals(libraryName, library.getName());
String[] binaryUrls = library.getUrls(CLASSES);
assertThat(binaryUrls).hasLength(1);
assertEquals(pathToIdeaUrl(binaryPath), binaryUrls[0]);
String[] sourceUrls = library.getUrls(SOURCES);
assertThat(sourceUrls).hasLength(1);
assertEquals(pathToIdeaUrl(sourcePath), sourceUrls[0]);
// Should not mark new libraries as "used"
verify(myLibraryRegistry, never()).markAsUsed(library, binaryPaths);
verify(myLibraryFilePaths).findSourceJarPath(binaryPath);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.
the class ContentRootsModuleSetupStepTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
initMocks(this);
myModuleFolder = getModuleFolder();
VirtualFile buildFolder = findOrCreateChildFolder(myModuleFolder, "build");
when(myAndroidProject.getBuildFolder()).thenReturn(virtualToIoFile(buildFolder));
when(myAndroidModel.getAndroidProject()).thenReturn(myAndroidProject);
when(myAndroidModel.getRootDir()).thenReturn(myModuleFolder);
when(myAndroidModel.getRootDirPath()).thenReturn(virtualToIoFile(myModuleFolder));
addContentRoots("a", "b", "c");
myModelsProvider = new IdeModifiableModelsProviderImpl(getProject());
mySetupStep = new ContentRootsModuleSetupStep(myFactory);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project intellij-community by JetBrains.
the class MavenProjectBuilder method commit.
@Override
public List<Module> commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider, ModifiableArtifactModel artifactModel) {
MavenWorkspaceSettings settings = MavenWorkspaceSettingsComponent.getInstance(project).getSettings();
settings.generalSettings = getGeneralSettings();
settings.importingSettings = getImportingSettings();
String settingsFile = System.getProperty("idea.maven.import.settings.file");
if (!StringUtil.isEmptyOrSpaces(settingsFile)) {
settings.generalSettings.setUserSettingsFile(settingsFile.trim());
}
MavenExplicitProfiles selectedProfiles = getSelectedProfiles();
String enabledProfilesList = System.getProperty("idea.maven.import.enabled.profiles");
String disabledProfilesList = System.getProperty("idea.maven.import.disabled.profiles");
if (enabledProfilesList != null || disabledProfilesList != null) {
selectedProfiles = selectedProfiles.clone();
appendProfilesFromString(selectedProfiles.getEnabledProfiles(), enabledProfilesList);
appendProfilesFromString(selectedProfiles.getDisabledProfiles(), disabledProfilesList);
}
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
manager.setIgnoredState(getParameters().mySelectedProjects, false);
manager.addManagedFilesWithProfiles(MavenUtil.collectFiles(getParameters().mySelectedProjects), selectedProfiles);
manager.waitForReadingCompletion();
boolean isFromUI = model != null;
return manager.importProjects(isFromUI ? new IdeUIModifiableModelsProvider(project, model, (ModulesConfigurator) modulesProvider, artifactModel) : new IdeModifiableModelsProviderImpl(project));
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project intellij-community by JetBrains.
the class FoldersImportingTest method testDoesNotResetUserFolders.
public void testDoesNotResetUserFolders() throws Exception {
final VirtualFile dir1 = createProjectSubDir("userSourceFolder");
final VirtualFile dir2 = createProjectSubDir("userExcludedFolder");
importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
ApplicationManager.getApplication().runWriteAction(() -> {
MavenRootModelAdapter adapter = new MavenRootModelAdapter(myProjectsTree.findProject(myProjectPom), getModule("project"), new IdeModifiableModelsProviderImpl(myProject));
adapter.addSourceFolder(dir1.getPath(), JavaSourceRootType.SOURCE);
adapter.addExcludedFolder(dir2.getPath());
adapter.getRootModel().commit();
});
assertSources("project", "userSourceFolder");
assertExcludes("project", "target", "userExcludedFolder");
importProject();
assertSources("project", "userSourceFolder");
assertExcludes("project", "target", "userExcludedFolder");
resolveFoldersAndImport();
assertSources("project", "userSourceFolder");
assertExcludes("project", "target", "userExcludedFolder");
}
Aggregations