Search in sources :

Example 6 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl 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());
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) JavaModuleModel(com.android.tools.idea.gradle.project.model.JavaModuleModel) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) Project(com.intellij.openapi.project.Project) ProjectLibraryTable(com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) File(java.io.File)

Example 7 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.

the class DependenciesModuleSetupStepTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initMocks(this);
    myModelsProvider = new IdeModifiableModelsProviderImpl(getProject());
    mySetupStep = new DependenciesModuleSetupStep(myDependenciesSetup);
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)

Example 8 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl 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);
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) Module(com.intellij.openapi.module.Module)

Example 9 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl 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);
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) Module(com.intellij.openapi.module.Module)

Example 10 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.

the class JavaLanguageLevelModuleSetupStepTest method testSetUpModuleWithLanguageLevelComingFromAndroidModules.

public void testSetUpModuleWithLanguageLevelComingFromAndroidModules() {
    createAndroidModule("app", JDK_1_7);
    createAndroidModule("androidLib", JDK_1_8);
    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_7);
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) Module(com.intellij.openapi.module.Module)

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