Search in sources :

Example 16 with GradleModuleModel

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

the class GradleModuleSetupTest method testSetUpModule.

public void testSetUpModule() {
    when(myModuleModels.getModule()).thenReturn(myModuleModel);
    when(myModuleModels.findModel(BuildScriptClasspathModel.class)).thenReturn(myClasspathModel);
    String gradleVersion = "2.14.1";
    when(myClasspathModel.getGradleVersion()).thenReturn(gradleVersion);
    myModuleSetup.setUpModule(myModule, myModelsProvider, myModuleModels);
    // Apply changes to verify state.
    ApplicationManager.getApplication().runWriteAction(() -> myModelsProvider.commit());
    GradleFacet facet = findFacet(myModule, myModelsProvider, GradleFacet.getFacetTypeId());
    assertNotNull(facet);
    GradleModuleModel gradleModuleModel = facet.getGradleModuleModel();
    assertNotNull(gradleModuleModel);
    assertEquals(":app", gradleModuleModel.getGradlePath());
    assertEquals(gradleVersion, gradleModuleModel.getGradleVersion());
    File buildFilePath = myModuleModel.getGradleProject().getBuildScript().getSourceFile();
    assertAbout(file()).that(gradleModuleModel.getBuildFilePath()).isEquivalentAccordingToCompareTo(buildFilePath);
    GradleVersion actualGradleVersion = mySyncSummary.getGradleVersion();
    assertNotNull(actualGradleVersion);
    assertEquals(gradleVersion, actualGradleVersion.toString());
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) GradleFacet(com.android.tools.idea.gradle.project.facet.gradle.GradleFacet) GradleVersion(com.android.ide.common.repository.GradleVersion) File(java.io.File)

Aggregations

GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)16 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)7 DataNode (com.intellij.openapi.externalSystem.model.DataNode)6 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)5 Module (com.intellij.openapi.module.Module)5 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)4 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)3 File (java.io.File)3 GradleProject (org.gradle.tooling.model.GradleProject)3 Nullable (org.jetbrains.annotations.Nullable)3 GradleScript (org.gradle.tooling.model.gradle.GradleScript)2 NotNull (org.jetbrains.annotations.NotNull)2 BuildScriptClasspathModel (org.jetbrains.plugins.gradle.model.BuildScriptClasspathModel)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1 AndroidProject (com.android.builder.model.AndroidProject)1 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)1 Variant (com.android.builder.model.Variant)1 GradleVersion (com.android.ide.common.repository.GradleVersion)1