use of com.android.tools.idea.gradle.dsl.model.java.JavaModel in project android by JetBrains.
the class GradleBuildModel method java.
@NotNull
public JavaModel java() {
JavaDslElement javaDslElement = myGradleDslFile.getPropertyElement(JAVA_BLOCK_NAME, JavaDslElement.class);
if (javaDslElement == null) {
javaDslElement = new JavaDslElement(myGradleDslFile);
myGradleDslFile.setNewElement(JAVA_BLOCK_NAME, javaDslElement);
}
return new JavaModel(javaDslElement);
}
use of com.android.tools.idea.gradle.dsl.model.java.JavaModel in project android by JetBrains.
the class SubProjectsTest method testOverrideSubProjectsSection.
public void testOverrideSubProjectsSection() throws Exception {
String settingsText = "include ':" + SUB_MODULE_NAME + "'";
String mainModuleText = "subprojects { \n" + " sourceCompatibility = 1.4\n" + " targetCompatibility = 1.5\n" + "}\n" + "sourceCompatibility = 1.5 \n" + "targetCompatibility = 1.6";
String subModuleText = "sourceCompatibility = 1.6\n" + "targetCompatibility = 1.7";
writeToSettingsFile(settingsText);
writeToBuildFile(mainModuleText);
writeToSubModuleBuildFile(subModuleText);
JavaModel java = getGradleBuildModel().java();
assertEquals(LanguageLevel.JDK_1_5, java.sourceCompatibility());
assertEquals(LanguageLevel.JDK_1_6, java.targetCompatibility());
JavaModel subModuleJava = getSubModuleGradleBuildModel().java();
// 1_4 is overridden with 1_6
assertEquals(LanguageLevel.JDK_1_6, subModuleJava.sourceCompatibility());
// 1_5 is overridden with 1_7
assertEquals(LanguageLevel.JDK_1_7, subModuleJava.targetCompatibility());
}
use of com.android.tools.idea.gradle.dsl.model.java.JavaModel in project android by JetBrains.
the class SubProjectsTest method testSubProjectsSection.
public void testSubProjectsSection() throws Exception {
String settingsText = "include ':" + SUB_MODULE_NAME + "'";
String mainModuleText = "subprojects { \n" + " sourceCompatibility = 1.5\n" + " targetCompatibility = 1.6\n" + "}";
String subModuleText = "";
writeToSettingsFile(settingsText);
writeToBuildFile(mainModuleText);
writeToSubModuleBuildFile(subModuleText);
JavaModel java = getGradleBuildModel().java();
assertNull(java.sourceCompatibility());
assertNull(java.targetCompatibility());
JavaModel subModuleJava = getSubModuleGradleBuildModel().java();
assertEquals(LanguageLevel.JDK_1_5, subModuleJava.sourceCompatibility());
assertEquals(LanguageLevel.JDK_1_6, subModuleJava.targetCompatibility());
}
use of com.android.tools.idea.gradle.dsl.model.java.JavaModel in project android by JetBrains.
the class SubProjectsTest method testSubProjectsSectionWithLocalProperties.
public void testSubProjectsSectionWithLocalProperties() throws Exception {
String settingsText = "include ':" + SUB_MODULE_NAME + "'";
String mainModuleText = "sourceCompatibility = 1.4 \n" + "targetCompatibility = 1.5 \n" + "subprojects { \n" + " sourceCompatibility = 1.5\n" + " targetCompatibility = 1.6\n" + "}";
String subModuleText = "";
writeToSettingsFile(settingsText);
writeToBuildFile(mainModuleText);
writeToSubModuleBuildFile(subModuleText);
JavaModel java = getGradleBuildModel().java();
// subprojects section applies only for sub projects.
assertEquals(LanguageLevel.JDK_1_4, java.sourceCompatibility());
// subprojects section applies only for sub projects.
assertEquals(LanguageLevel.JDK_1_5, java.targetCompatibility());
JavaModel subModuleJava = getSubModuleGradleBuildModel().java();
// Subproject got 1_5 from SubProjects section
assertEquals(LanguageLevel.JDK_1_5, subModuleJava.sourceCompatibility());
// Subproject got 1_6 from SubProjects section
assertEquals(LanguageLevel.JDK_1_6, subModuleJava.targetCompatibility());
}
Aggregations