Search in sources :

Example 6 with ProductFlavorModel

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

the class ExtModelTest method testResolveMultiLevelExtProperty.

public void testResolveMultiLevelExtProperty() throws IOException {
    String text = "ext.SDK_VERSION = 21\n" + "ext.COMPILE_SDK_VERSION = SDK_VERSION\n" + "android {\n" + "  compileSdkVersion COMPILE_SDK_VERSION\n" + "  defaultConfig {\n" + "    targetSdkVersion compileSdkVersion\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    ExtModel extModel = buildModel.ext();
    assertEquals(21, extModel.getLiteralProperty("SDK_VERSION", Integer.class));
    assertEquals(21, extModel.getLiteralProperty("COMPILE_SDK_VERSION", Integer.class));
    AndroidModel androidModel = buildModel.android();
    assertNotNull(androidModel);
    assertEquals("compileSdkVersion", "21", androidModel.compileSdkVersion());
    ProductFlavorModel defaultConfig = androidModel.defaultConfig();
    assertEquals("targetSdkVersion", "21", defaultConfig.targetSdkVersion());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel) ProductFlavorModel(com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)

Example 7 with ProductFlavorModel

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

the class ExtModelTest method testResolveQualifiedVariableInStringLiteral.

public void testResolveQualifiedVariableInStringLiteral() throws IOException {
    String text = "android {\n" + "  compileSdkVersion 23\n" + "  defaultConfig {\n" + "    targetSdkVersion \"$android.compileSdkVersion\"\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel androidModel = buildModel.android();
    assertNotNull(androidModel);
    assertEquals("compileSdkVersion", "23", androidModel.compileSdkVersion());
    ProductFlavorModel defaultConfig = androidModel.defaultConfig();
    assertEquals("targetSdkVersion", "23", defaultConfig.targetSdkVersion());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel) ProductFlavorModel(com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)

Example 8 with ProductFlavorModel

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

the class ExtModelTest method testStringReferenceInMapProperty.

public void testStringReferenceInMapProperty() throws IOException {
    String text = "ext.TEST_STRING = \"test\"\n" + "android.defaultConfig {\n" + "    testInstrumentationRunnerArguments size:\"medium\", foo:TEST_STRING\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    ExtModel extModel = buildModel.ext();
    assertEquals("test", extModel.getLiteralProperty("TEST_STRING", String.class));
    AndroidModel androidModel = buildModel.android();
    assertNotNull(androidModel);
    ProductFlavorModel defaultConfig = androidModel.defaultConfig();
    assertEquals("testInstrumentationRunnerArguments", ImmutableMap.of("size", "medium", "foo", "test"), defaultConfig.testInstrumentationRunnerArguments());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel) ProductFlavorModel(com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)

Example 9 with ProductFlavorModel

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

the class GradleValueTest method testListOfGradleValuesInApplicationStatements.

public void testListOfGradleValuesInApplicationStatements() throws Exception {
    String text = "android {\n" + "  defaultConfig {\n" + "    consumerProguardFiles 'con-proguard-android.txt', 'con-proguard-rules.pro'\n" + "    proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    resConfigs 'abcd', 'efgh'" + "  }\n" + "}";
    writeToBuildFile(text);
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    ProductFlavorModel defaultConfig = android.defaultConfig();
    List<GradleNotNullValue<String>> consumerProguardFiles = defaultConfig.consumerProguardFiles();
    assertNotNull(consumerProguardFiles);
    assertThat(consumerProguardFiles).hasSize(2);
    verifyGradleValue(consumerProguardFiles.get(0), "android.defaultConfig.consumerProguardFiles.consumerProguardFiles", "'con-proguard-android.txt'");
    verifyGradleValue(consumerProguardFiles.get(1), "android.defaultConfig.consumerProguardFiles.consumerProguardFiles", "'con-proguard-rules.pro'");
    List<GradleNotNullValue<String>> proguardFiles = defaultConfig.proguardFiles();
    assertNotNull(proguardFiles);
    assertThat(proguardFiles).hasSize(2);
    verifyGradleValue(proguardFiles.get(0), "android.defaultConfig.proguardFiles.proguardFiles", "'proguard-android.txt'");
    verifyGradleValue(proguardFiles.get(1), "android.defaultConfig.proguardFiles.proguardFiles", "'proguard-rules.pro'");
    List<GradleNotNullValue<String>> resConfigs = defaultConfig.resConfigs();
    assertNotNull(resConfigs);
    assertThat(resConfigs).hasSize(2);
    verifyGradleValue(resConfigs.get(0), "android.defaultConfig.resConfigs.resConfigs", "'abcd'");
    verifyGradleValue(resConfigs.get(1), "android.defaultConfig.resConfigs.resConfigs", "'efgh'");
}
Also used : AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel) ProductFlavorModel(com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)

Example 10 with ProductFlavorModel

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

the class GradleValueTest method testMapOfGradleValuesInAssignmentStatements.

public void testMapOfGradleValuesInAssignmentStatements() throws Exception {
    String text = "android {\n" + "  defaultConfig {\n" + "    manifestPlaceholders = [activityLabel1:\"defaultName1\", activityLabel2:\"defaultName2\"]\n" + "    testInstrumentationRunnerArguments = [size:\"medium\", foo:\"bar\"]\n" + "  }\n" + "}";
    writeToBuildFile(text);
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    ProductFlavorModel defaultConfig = android.defaultConfig();
    Map<String, GradleNotNullValue<Object>> manifestPlaceholders = defaultConfig.manifestPlaceholders();
    assertNotNull(manifestPlaceholders);
    GradleNotNullValue<Object> activityLabel1 = manifestPlaceholders.get("activityLabel1");
    assertNotNull(activityLabel1);
    verifyGradleValue(activityLabel1, "android.defaultConfig.manifestPlaceholders.activityLabel1", "\"defaultName1\"");
    GradleNotNullValue<Object> activityLabel2 = manifestPlaceholders.get("activityLabel2");
    assertNotNull(activityLabel2);
    verifyGradleValue(activityLabel2, "android.defaultConfig.manifestPlaceholders.activityLabel2", "\"defaultName2\"");
    Map<String, GradleNotNullValue<String>> testInstrumentationRunnerArguments = defaultConfig.testInstrumentationRunnerArguments();
    assertNotNull(testInstrumentationRunnerArguments);
    GradleNotNullValue<String> size = testInstrumentationRunnerArguments.get("size");
    assertNotNull(size);
    verifyGradleValue(size, "android.defaultConfig.testInstrumentationRunnerArguments.size", "\"medium\"");
    GradleNotNullValue<String> foo = testInstrumentationRunnerArguments.get("foo");
    assertNotNull(foo);
    verifyGradleValue(foo, "android.defaultConfig.testInstrumentationRunnerArguments.foo", "\"bar\"");
}
Also used : AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel) ProductFlavorModel(com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)

Aggregations

AndroidModel (com.android.tools.idea.gradle.dsl.model.android.AndroidModel)13 ProductFlavorModel (com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)13 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)8 AbstractFlavorTypeModel (com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel)1 BuildTypeModel (com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel)1 GradleDslExpressionList (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpressionList)1