Search in sources :

Example 1 with SourceDirectoryModel

use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.

the class SourceSetModel method jni.

@NotNull
public SourceDirectoryModel jni() {
    SourceDirectoryDslElement jni = myDslElement.getPropertyElement(JNI, SourceDirectoryDslElement.class);
    if (jni == null) {
        jni = new SourceDirectoryDslElement(myDslElement, JNI);
        myDslElement.setNewElement(JNI, jni);
    }
    return new SourceDirectoryModel(jni);
}
Also used : SourceDirectoryModel(com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel) SourceDirectoryDslElement(com.android.tools.idea.gradle.dsl.parser.android.sourceSets.SourceDirectoryDslElement) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with SourceDirectoryModel

use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.

the class SourceDirectoryModelTest method testSourceDirectoryEntriesAddAndReset.

public void testSourceDirectoryEntriesAddAndReset() 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.addSrcDir("javaSource3");
    java.addInclude("javaInclude3");
    java.addExclude("javaExclude3");
    SourceDirectoryModel jni = sourceSet.jni();
    jni.addSrcDir("jniSource3");
    jni.addInclude("jniInclude3");
    jni.addExclude("jniExclude3");
    verifySourceDirectoryEntries(buildModel, 1, 2, 3);
    buildModel.resetState();
    verifySourceDirectoryEntries(buildModel, 1, 2);
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) SourceDirectoryModel(com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel)

Example 3 with SourceDirectoryModel

use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.

the class SourceDirectoryModelTest method testSourceDirectoryEntriesRemoveAndApply.

public void testSourceDirectoryEntriesRemoveAndApply() 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);
    applyChangesAndReparse(buildModel);
    verifySourceDirectoryEntries(buildModel, 1);
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) SourceDirectoryModel(com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel)

Example 4 with SourceDirectoryModel

use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.

the class SourceDirectoryModelTest method testSourceDirectoryEntriesReplaceAndReset.

public void testSourceDirectoryEntriesReplaceAndReset() 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("javaSource2", "javaSource3");
    java.replaceInclude("javaInclude2", "javaInclude3");
    java.replaceExclude("javaExclude2", "javaExclude3");
    SourceDirectoryModel jni = sourceSet.jni();
    jni.replaceSrcDir("jniSource2", "jniSource3");
    jni.replaceInclude("jniInclude2", "jniInclude3");
    jni.replaceExclude("jniExclude2", "jniExclude3");
    verifySourceDirectoryEntries(buildModel, 1, 3);
    buildModel.resetState();
    verifySourceDirectoryEntries(buildModel, 1, 2);
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) SourceDirectoryModel(com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel)

Example 5 with SourceDirectoryModel

use of com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel in project android by JetBrains.

the class SourceDirectoryModelTest method testSourceDirectoryEntriesRemoveAllAndReset.

public void testSourceDirectoryEntriesRemoveAllAndReset() 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);
    buildModel.resetState();
    verifySourceDirectoryEntries(buildModel, 1, 2);
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) SourceDirectoryModel(com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel)

Aggregations

SourceDirectoryModel (com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel)17 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)8 SourceDirectoryDslElement (com.android.tools.idea.gradle.dsl.parser.android.sourceSets.SourceDirectoryDslElement)8 NotNull (org.jetbrains.annotations.NotNull)8 SourceFileModel (com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceFileModel)1