Search in sources :

Example 11 with ProductFlavorModel

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

the class GradleValueTest method testGradleValuesOfTypeNameValueElements.

public void testGradleValuesOfTypeNameValueElements() throws Exception {
    String text = "android {\n" + "  defaultConfig {\n" + "    resValue \"abcd\", \"efgh\", \"ijkl\"\n" + "  }\n" + "  buildTypes {\n" + "    xyz {\n" + "      buildConfigField \"mnop\", \"qrst\", \"uvwx\"\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    ProductFlavorModel defaultConfig = android.defaultConfig();
    List<GradleNotNullValue<AbstractFlavorTypeModel.ResValue>> resValues = defaultConfig.resValues();
    assertNotNull(resValues);
    assertThat(resValues).hasSize(1);
    verifyGradleValue(resValues.get(0), "android.defaultConfig.resValue", "\"abcd\", \"efgh\", \"ijkl\"");
    List<BuildTypeModel> buildTypes = android.buildTypes();
    assertThat(buildTypes).hasSize(1);
    List<GradleNotNullValue<BuildTypeModel.BuildConfigField>> buildConfigFields = buildTypes.get(0).buildConfigFields();
    assertNotNull(buildConfigFields);
    assertThat(buildConfigFields).hasSize(1);
    verifyGradleValue(buildConfigFields.get(0), "android.buildTypes.xyz.buildConfigField", "\"mnop\", \"qrst\", \"uvwx\"");
}
Also used : AndroidModel(com.android.tools.idea.gradle.dsl.model.android.AndroidModel) ProductFlavorModel(com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel) AbstractFlavorTypeModel(com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel) BuildTypeModel(com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel)

Example 12 with ProductFlavorModel

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

the class ExtModelTest method testResolveVariablesInStringLiteral.

public void testResolveVariablesInStringLiteral() throws IOException {
    String text = "ext.ANDROID = \"android\"\n" + "ext.SDK_VERSION = 23\n" + "android {\n" + "  compileSdkVersion = \"$ANDROID-${SDK_VERSION}\"\n" + "  defaultConfig {\n" + "    targetSdkVersion \"$compileSdkVersion\"\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    ExtModel extModel = buildModel.ext();
    assertEquals("android", extModel.getLiteralProperty("ANDROID", String.class));
    assertEquals(23, extModel.getLiteralProperty("SDK_VERSION", Integer.class));
    AndroidModel androidModel = buildModel.android();
    assertNotNull(androidModel);
    assertEquals("compileSdkVersion", "android-23", androidModel.compileSdkVersion());
    ProductFlavorModel defaultConfig = androidModel.defaultConfig();
    assertEquals("targetSdkVersion", "android-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 13 with ProductFlavorModel

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

the class ExtModelTest method testResolveVariableInListProperty.

public void testResolveVariableInListProperty() throws IOException {
    String text = "ext.TEST_STRING = \"test\"\n" + "android.defaultConfig {\n" + "    proguardFiles 'proguard-android.txt', \"$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("proguardFiles", ImmutableList.of("proguard-android.txt", "test"), defaultConfig.proguardFiles());
}
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)

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