use of com.android.tools.idea.gradle.dsl.model.ext.ExtModel in project android by JetBrains.
the class ReferenceResolutionTest method testResolveProjectDir.
public void testResolveProjectDir() throws Exception {
String settingsText = "include ':" + SUB_MODULE_NAME + "'";
String mainModuleText = "";
String subModuleText = "ext {\n" + " pd = projectDir\n" + " pd1 = project.projectDir\n" + " pd2 = parent.projectDir\n" + " pd3 = rootProject.projectDir\n" + " pd4 = project(':" + SUB_MODULE_NAME + "').projectDir\n" + " pd5 = project(':').projectDir\n" + "}";
writeToSettingsFile(settingsText);
writeToBuildFile(mainModuleText);
writeToSubModuleBuildFile(subModuleText);
String expectedRootDir = getBaseDirPath(myProject).getPath();
String expectedSubModuleDir = mySubModuleBuildFile.getParent();
ExtModel ext = getSubModuleGradleBuildModel().ext();
assertEquals("projectDir", expectedSubModuleDir, ext.getLiteralProperty("pd", String.class));
assertEquals("projectDir", expectedSubModuleDir, ext.getLiteralProperty("pd1", String.class));
assertEquals("projectDir", expectedRootDir, ext.getLiteralProperty("pd2", String.class));
assertEquals("projectDir", expectedRootDir, ext.getLiteralProperty("pd3", String.class));
assertEquals("projectDir", expectedSubModuleDir, ext.getLiteralProperty("pd4", String.class));
assertEquals("projectDir", expectedRootDir, ext.getLiteralProperty("pd5", String.class));
}
use of com.android.tools.idea.gradle.dsl.model.ext.ExtModel in project android by JetBrains.
the class GradleBuildModel method ext.
@NotNull
public ExtModel ext() {
ExtDslElement extDslElement = myGradleDslFile.getPropertyElement(EXT_BLOCK_NAME, ExtDslElement.class);
if (extDslElement == null) {
extDslElement = new ExtDslElement(myGradleDslFile);
myGradleDslFile.setNewElement(EXT_BLOCK_NAME, extDslElement);
}
return new ExtModel(extDslElement);
}
use of com.android.tools.idea.gradle.dsl.model.ext.ExtModel in project android by JetBrains.
the class ReferenceResolutionTest method testResolveRootDir.
public void testResolveRootDir() throws Exception {
String settingsText = "include ':" + SUB_MODULE_NAME + "'";
String mainModuleText = "";
String subModuleText = "ext {\n" + " rpd = rootDir\n" + " rpd1 = project.rootDir\n" + " rpd2 = parent.rootDir\n" + " rpd3 = rootProject.rootDir\n" + " rpd4 = project(':" + SUB_MODULE_NAME + "').rootDir\n" + " rpd5 = project(':').rootDir\n" + "}";
writeToSettingsFile(settingsText);
writeToBuildFile(mainModuleText);
writeToSubModuleBuildFile(subModuleText);
String expectedRootDir = getBaseDirPath(myProject).getPath();
ExtModel ext = getSubModuleGradleBuildModel().ext();
assertEquals("rootDir", expectedRootDir, ext.getLiteralProperty("rpd", String.class));
assertEquals("rootDir", expectedRootDir, ext.getLiteralProperty("rpd1", String.class));
assertEquals("rootDir", expectedRootDir, ext.getLiteralProperty("rpd2", String.class));
assertEquals("rootDir", expectedRootDir, ext.getLiteralProperty("rpd3", String.class));
assertEquals("rootDir", expectedRootDir, ext.getLiteralProperty("rpd4", String.class));
assertEquals("rootDir", expectedRootDir, ext.getLiteralProperty("rpd5", String.class));
}
Aggregations