Search in sources :

Example 16 with IdeModifiableModelsProviderImpl

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);
}
Also used : DataNode(com.intellij.openapi.externalSystem.model.DataNode) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) Module(com.intellij.openapi.module.Module) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel)

Example 17 with IdeModifiableModelsProviderImpl

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);
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) File(java.io.File)

Example 18 with IdeModifiableModelsProviderImpl

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)

Example 19 with IdeModifiableModelsProviderImpl

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));
}
Also used : IdeUIModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeUIModifiableModelsProvider) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)

Example 20 with IdeModifiableModelsProviderImpl

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");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)

Aggregations

IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)36 IdeModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)18 Module (com.intellij.openapi.module.Module)16 Project (com.intellij.openapi.project.Project)9 File (java.io.File)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 DataNode (com.intellij.openapi.externalSystem.model.DataNode)4 Library (com.intellij.openapi.roots.libraries.Library)4 JavaModuleModel (com.android.tools.idea.gradle.project.model.JavaModuleModel)3 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 FacetManager (com.intellij.facet.FacetManager)2 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)2 IdeUIModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeUIModifiableModelsProvider)2 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 ArrayList (java.util.ArrayList)2 MavenRootModelAdapter (org.jetbrains.idea.maven.importing.MavenRootModelAdapter)2 AndroidProject (com.android.builder.model.AndroidProject)1