Search in sources :

Example 11 with JavaModuleModel

use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.

the class JavaFacetModuleSetupStepTest method testDoSetUpModuleWithoutGradleFacet.

public void testDoSetUpModuleWithoutGradleFacet() throws IOException {
    File buildFolderPath = createTempDir("build", true);
    boolean buildable = true;
    JavaModuleModel javaModel = mock(JavaModuleModel.class);
    when(javaModel.getBuildFolderPath()).thenReturn(buildFolderPath);
    when(javaModel.isBuildable()).thenReturn(buildable);
    Module module = getModule();
    mySetupStep.doSetUpModule(module, myModelsProvider, javaModel, null, null);
    ApplicationManager.getApplication().runWriteAction(() -> myModelsProvider.commit());
    JavaFacet facet = findJavaFacet(module);
    assertNotNull(facet);
    assertNull(facet.getJavaModuleModel());
}
Also used : Facets.createAndAddJavaFacet(com.android.tools.idea.testing.Facets.createAndAddJavaFacet) JavaFacet(com.android.tools.idea.gradle.project.facet.java.JavaFacet) JavaModuleModel(com.android.tools.idea.gradle.project.model.JavaModuleModel) Module(com.intellij.openapi.module.Module) File(java.io.File)

Example 12 with JavaModuleModel

use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.

the class JavaFacetModuleSetupStepTest method testDoSetUpModuleWithExistingJavaFacet.

public void testDoSetUpModuleWithExistingJavaFacet() throws IOException {
    createAndAddGradleFacet(getModule());
    JavaFacet facet = createAndAddJavaFacet(getModule());
    File buildFolderPath = createTempDir("build", true);
    boolean buildable = true;
    JavaModuleModel javaModel = mock(JavaModuleModel.class);
    when(javaModel.getBuildFolderPath()).thenReturn(buildFolderPath);
    when(javaModel.isBuildable()).thenReturn(buildable);
    Module module = getModule();
    mySetupStep.doSetUpModule(module, myModelsProvider, javaModel, null, null);
    ApplicationManager.getApplication().runWriteAction(() -> myModelsProvider.commit());
    // JavaFacet should be reused.
    assertSame(facet, findJavaFacet(module));
    verifyFacetConfiguration(facet, javaModel, buildFolderPath, buildable);
}
Also used : Facets.createAndAddJavaFacet(com.android.tools.idea.testing.Facets.createAndAddJavaFacet) JavaFacet(com.android.tools.idea.gradle.project.facet.java.JavaFacet) JavaModuleModel(com.android.tools.idea.gradle.project.model.JavaModuleModel) Module(com.intellij.openapi.module.Module) File(java.io.File)

Aggregations

JavaModuleModel (com.android.tools.idea.gradle.project.model.JavaModuleModel)12 Module (com.intellij.openapi.module.Module)7 File (java.io.File)6 JavaFacet (com.android.tools.idea.gradle.project.facet.java.JavaFacet)4 Facets.createAndAddJavaFacet (com.android.tools.idea.testing.Facets.createAndAddJavaFacet)3 IdeModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)3 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)3 Project (com.intellij.openapi.project.Project)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 Library (com.intellij.openapi.roots.libraries.Library)2 ModuleExtendedModel (org.jetbrains.plugins.gradle.model.ModuleExtendedModel)2 ArtifactDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel)1 JarLibraryDependency (com.android.tools.idea.gradle.model.java.JarLibraryDependency)1 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)1 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)1 SourceFileContainerInfo (com.android.tools.idea.gradle.project.model.AndroidModuleModel.SourceFileContainerInfo)1 GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)1 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)1