use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.
the class SourceSetModel method jniLibs.
@NotNull
public SourceDirectoryModel jniLibs() {
SourceDirectoryDslElement jniLibs = myDslElement.getPropertyElement(JNI_LIBS, SourceDirectoryDslElement.class);
if (jniLibs == null) {
jniLibs = new SourceDirectoryDslElement(myDslElement, JNI_LIBS);
myDslElement.setNewElement(JNI_LIBS, jniLibs);
}
return new SourceDirectoryModel(jniLibs);
}
use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.
the class SourceSetModel method res.
@NotNull
public SourceDirectoryModel res() {
SourceDirectoryDslElement res = myDslElement.getPropertyElement(RES, SourceDirectoryDslElement.class);
if (res == null) {
res = new SourceDirectoryDslElement(myDslElement, RES);
myDslElement.setNewElement(RES, res);
}
return new SourceDirectoryModel(res);
}
use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.
the class SourceDirectoryModelTest method testSourceDirectoryEntriesReplaceAndApply.
public void testSourceDirectoryEntriesReplaceAndApply() throws Exception {
writeToBuildFile(GRADLE_TEXT);
GradleBuildModel buildModel = getGradleBuildModel();
verifySourceDirectoryEntries(buildModel, 1, 2);
AndroidModel android = buildModel.android();
assertNotNull(android);
SourceSetModel sourceSet = android.sourceSets().get(0);
SourceDirectoryModel java = sourceSet.java();
java.replaceSrcDir("javaSource1", "javaSource0");
java.replaceInclude("javaInclude1", "javaInclude0");
java.replaceExclude("javaExclude1", "javaExclude0");
SourceDirectoryModel jni = sourceSet.jni();
jni.replaceSrcDir("jniSource1", "jniSource0");
jni.replaceInclude("jniInclude1", "jniInclude0");
jni.replaceExclude("jniExclude1", "jniExclude0");
verifySourceDirectoryEntries(buildModel, 0, 2);
applyChangesAndReparse(buildModel);
verifySourceDirectoryEntries(buildModel, 0, 2);
}
use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.
the class SourceDirectoryModelTest method testSourceDirectoryEntriesRemoveAllAndApply.
public void testSourceDirectoryEntriesRemoveAllAndApply() throws Exception {
writeToBuildFile(GRADLE_TEXT);
GradleBuildModel buildModel = getGradleBuildModel();
verifySourceDirectoryEntries(buildModel, 1, 2);
AndroidModel android = buildModel.android();
assertNotNull(android);
SourceSetModel sourceSet = android.sourceSets().get(0);
SourceDirectoryModel java = sourceSet.java();
java.removeAllSrcDirs();
java.removeAllIncludes();
java.removeAllExcludes();
SourceDirectoryModel jni = sourceSet.jni();
jni.removeAllSrcDirs();
jni.removeAllIncludes();
jni.removeAllExcludes();
verifySourceDirectoryEntries(buildModel);
applyChangesAndReparse(buildModel);
android = buildModel.android();
assertNotNull(android);
// Whole android block gets removed as it would become empty.
assertFalse(android.hasValidPsiElement());
assertEmpty(android.sourceSets());
}
use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.
the class SourceDirectoryModelTest method testSourceDirectoryEntriesRemoveAndReset.
public void testSourceDirectoryEntriesRemoveAndReset() throws Exception {
writeToBuildFile(GRADLE_TEXT);
GradleBuildModel buildModel = getGradleBuildModel();
verifySourceDirectoryEntries(buildModel, 1, 2);
AndroidModel android = buildModel.android();
assertNotNull(android);
SourceSetModel sourceSet = android.sourceSets().get(0);
SourceDirectoryModel java = sourceSet.java();
java.removeSrcDir("javaSource2");
java.removeInclude("javaInclude2");
java.removeExclude("javaExclude2");
SourceDirectoryModel jni = sourceSet.jni();
jni.removeSrcDir("jniSource2");
jni.removeInclude("jniInclude2");
jni.removeExclude("jniExclude2");
verifySourceDirectoryEntries(buildModel, 1);
buildModel.resetState();
verifySourceDirectoryEntries(buildModel, 1, 2);
}
Aggregations