use of com.android.tools.idea.gradle.dsl.model.android.AndroidModel in project android by JetBrains.
the class ExtModelTest method testResolveExtProperty.
public void testResolveExtProperty() throws IOException {
String text = "ext.COMPILE_SDK_VERSION = 21\n" + "android {\n" + " compileSdkVersion COMPILE_SDK_VERSION\n" + "}";
writeToBuildFile(text);
ExtModel extModel = getGradleBuildModel().ext();
assertEquals(21, extModel.getLiteralProperty("COMPILE_SDK_VERSION", Integer.class));
AndroidModel androidModel = getGradleBuildModel().android();
assertNotNull(androidModel);
assertEquals("compileSdkVersion", "21", androidModel.compileSdkVersion());
}
use of com.android.tools.idea.gradle.dsl.model.android.AndroidModel 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.AndroidModel in project android by JetBrains.
the class ExtModelTest method testResolveMultiModuleExtProperty.
public void testResolveMultiModuleExtProperty() throws IOException {
String settingsText = "include ':" + SUB_MODULE_NAME + "'";
String mainModuleText = "ext.SDK_VERSION = 21";
String subModuleText = "android {\n" + " compileSdkVersion SDK_VERSION\n" + "}";
writeToSettingsFile(settingsText);
writeToBuildFile(mainModuleText);
writeToSubModuleBuildFile(subModuleText);
GradleBuildModel buildModel = getGradleBuildModel();
ExtModel extModel = buildModel.ext();
assertEquals(21, extModel.getLiteralProperty("SDK_VERSION", Integer.class));
GradleBuildModel subModuleBuildModel = getSubModuleGradleBuildModel();
ExtModel subModuleExtModel = subModuleBuildModel.ext();
// SDK_VERSION is not defined in the sub module.
assertNull(subModuleExtModel.getLiteralProperty("SDK_VERSION", Integer.class).value());
AndroidModel androidModel = subModuleBuildModel.android();
assertNotNull(androidModel);
// SDK_VERSION resolved from the main module.
assertEquals("compileSdkVersion", "21", androidModel.compileSdkVersion());
}
use of com.android.tools.idea.gradle.dsl.model.android.AndroidModel in project android by JetBrains.
the class ExtModelTest method testResolveQualifiedExtProperty.
public void testResolveQualifiedExtProperty() throws IOException {
String text = "ext.constants = [\n" + " COMPILE_SDK_VERSION : 21\n" + "]\n" + "android {\n" + " compileSdkVersion constants.COMPILE_SDK_VERSION\n" + "}";
writeToBuildFile(text);
ExtModel extModel = getGradleBuildModel().ext();
assertEquals(21, extModel.getLiteralProperty("constants.COMPILE_SDK_VERSION", Integer.class));
AndroidModel androidModel = getGradleBuildModel().android();
assertNotNull(androidModel);
assertEquals("compileSdkVersion", "21", androidModel.compileSdkVersion());
}
use of com.android.tools.idea.gradle.dsl.model.android.AndroidModel 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