Search in sources :

Example 26 with AndroidModel

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

the class ReferenceResolutionTest method testResolveProjectPath.

public void testResolveProjectPath() throws Exception {
    String settingsText = "include ':" + SUB_MODULE_NAME + "'";
    String mainModuleText = "";
    String subModuleText = "android {\n" + "  compileSdkVersion = \"android-23\"\n" + "  defaultConfig {\n" + "    minSdkVersion = project(':" + SUB_MODULE_NAME + "').android.compileSdkVersion\n" + "  }\n" + "}";
    writeToSettingsFile(settingsText);
    writeToBuildFile(mainModuleText);
    writeToSubModuleBuildFile(subModuleText);
    AndroidModel android = getSubModuleGradleBuildModel().android();
    assertNotNull(android);
    assertEquals("compileSdkVersion", "android-23", android.compileSdkVersion());
    assertEquals("minSdkVersion", "android-23", android.defaultConfig().minSdkVersion());
}
Also used : AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel)

Example 27 with AndroidModel

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

the class ReferenceResolutionTest method testResolveProject.

public void testResolveProject() throws Exception {
    String settingsText = "include ':" + SUB_MODULE_NAME + "'";
    String mainModuleText = "";
    String subModuleText = "android {\n" + "  compileSdkVersion = \"android-23\"\n" + "  defaultConfig {\n" + "    minSdkVersion = project.android.compileSdkVersion\n" + "  }\n" + "}";
    writeToSettingsFile(settingsText);
    writeToBuildFile(mainModuleText);
    writeToSubModuleBuildFile(subModuleText);
    AndroidModel android = getSubModuleGradleBuildModel().android();
    assertNotNull(android);
    assertEquals("compileSdkVersion", "android-23", android.compileSdkVersion());
    assertEquals("minSdkVersion", "android-23", android.defaultConfig().minSdkVersion());
}
Also used : AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel)

Example 28 with AndroidModel

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

the class ReferenceResolutionTest method testResolveOtherProjectPath.

public void testResolveOtherProjectPath() throws Exception {
    String settingsText = "include ':" + SUB_MODULE_NAME + "'";
    String mainModuleText = "android {\n" + "  compileSdkVersion = \"android-23\"\n" + "}";
    String subModuleText = "android {\n" + "  compileSdkVersion = project(':').android.compileSdkVersion\n" + "}";
    writeToSettingsFile(settingsText);
    writeToBuildFile(mainModuleText);
    writeToSubModuleBuildFile(subModuleText);
    AndroidModel androidModel = getGradleBuildModel().android();
    assertNotNull(androidModel);
    assertEquals("compileSdkVersion", "android-23", androidModel.compileSdkVersion());
    AndroidModel subModuleAndroidModel = getSubModuleGradleBuildModel().android();
    assertNotNull(subModuleAndroidModel);
    assertEquals("compileSdkVersion", "android-23", subModuleAndroidModel.compileSdkVersion());
}
Also used : AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel)

Aggregations

AndroidModel (com.android.tools.idea.gradle.dsl.model.android.AndroidModel)28 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)13 ProductFlavorModel (com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)13 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 Project (com.intellij.openapi.project.Project)2 Nullable (org.jetbrains.annotations.Nullable)2 AbstractFlavorTypeModel (com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel)1 BuildTypeModel (com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel)1 CompileOptionsModel (com.android.tools.idea.gradle.dsl.model.android.CompileOptionsModel)1 JavaModel (com.android.tools.idea.gradle.dsl.model.java.JavaModel)1 AndroidDslElement (com.android.tools.idea.gradle.dsl.parser.android.AndroidDslElement)1 GradleDslExpressionList (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionList)1 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)1 JavaFacet (com.android.tools.idea.gradle.project.facet.java.JavaFacet)1 Projects.getAndroidModel (com.android.tools.idea.gradle.util.Projects.getAndroidModel)1 Module (com.intellij.openapi.module.Module)1 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1