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\"");
}
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());
}
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());
}
Aggregations