Search in sources :

Example 96 with GradleBuildModel

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

the class SplitsModelTest method testAddResetStatement.

public void testAddResetStatement() throws Exception {
    String text = "android {\n" + "  splits {\n" + "    abi {\n" + "      include 'abi-include-1', 'abi-include-2'\n" + "    }\n" + "    density {\n" + "      include 'density-include-1', 'density-include-2'\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    assertEquals("abi-include", ImmutableList.of("abi-include-1", "abi-include-2"), splits.abi().include());
    assertEquals("density-include", ImmutableList.of("density-include-1", "density-include-2"), splits.density().include());
    splits.abi().addReset();
    splits.density().addReset();
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    splits = android.splits();
    assertNull("abi-include", splits.abi().include());
    assertNull("density-include", splits.density().include());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel)

Example 97 with GradleBuildModel

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

the class TestOptionsModelTest method testRemoveElements.

public void testRemoveElements() throws Exception {
    writeToBuildFile(TEST_OPTIONS_TEXT);
    verifyTestOptionsValues();
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    TestOptionsModel testOptions = android.testOptions();
    assertTrue(testOptions.hasValidPsiElement());
    testOptions.removeReportDir();
    testOptions.removeResultsDir();
    testOptions.unitTests().removeReturnDefaultValues();
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    testOptions = android.testOptions();
    verifyNullTestOptionsValues();
    assertFalse(testOptions.hasValidPsiElement());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel)

Example 98 with GradleBuildModel

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

the class SourceFileModelTest method testSourceFileRemoveAndApply.

public void testSourceFileRemoveAndApply() throws Exception {
    String text = "android {\n" + "  sourceSets {\n" + "    main {\n" + "      manifest {\n" + "        srcFile \"mainSource.xml\"\n" + "      }\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    verifySourceFile(buildModel, "mainSource.xml");
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    android.sourceSets().get(0).manifest().removeSrcFile();
    verifySourceFile(buildModel, null);
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    // Whole android block gets removed as it would become empty.
    assertFalse(android.hasValidPsiElement());
    assertThat(android.sourceSets()).isEmpty();
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel)

Example 99 with GradleBuildModel

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

the class SourceFileModelTest method testSourceFileAddAndApply.

public void testSourceFileAddAndApply() throws Exception {
    String text = "android {\n" + "  sourceSets {\n" + "    main {\n" + "      manifest {\n" + "      }\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    verifySourceFile(buildModel, null);
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    android.sourceSets().get(0).manifest().setSrcFile("mainSource.xml");
    verifySourceFile(buildModel, "mainSource.xml");
    applyChangesAndReparse(buildModel);
    verifySourceFile(buildModel, "mainSource.xml");
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel)

Example 100 with GradleBuildModel

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

the class SourceFileModelTest method testSourceFileEditAndApply.

public void testSourceFileEditAndApply() throws Exception {
    String text = "android {\n" + "  sourceSets {\n" + "    main {\n" + "      manifest {\n" + "        srcFile \"mainSource.xml\"\n" + "      }\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    verifySourceFile(buildModel, "mainSource.xml");
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    android.sourceSets().get(0).manifest().setSrcFile("otherSource.xml");
    verifySourceFile(buildModel, "otherSource.xml");
    applyChangesAndReparse(buildModel);
    verifySourceFile(buildModel, "otherSource.xml");
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel)

Aggregations

GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)285 ResValue (com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue)20 ArtifactDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel)17 SigningConfigPassword (com.android.tools.idea.gradle.dsl.model.android.SigningConfigModel.SigningConfigPassword)15 AndroidModel (com.android.tools.idea.gradle.dsl.model.android.AndroidModel)13 DependenciesModel (com.android.tools.idea.gradle.dsl.model.dependencies.DependenciesModel)13 File (java.io.File)13 Project (com.intellij.openapi.project.Project)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 BuildConfigField (com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField)10 Module (com.intellij.openapi.module.Module)9 ProductFlavorModel (com.android.tools.idea.gradle.dsl.model.android.ProductFlavorModel)8 SourceDirectoryModel (com.android.tools.idea.gradle.dsl.model.android.sourceSets.SourceDirectoryModel)8 Result (com.intellij.openapi.application.Result)8 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)8 GradleNotNullValue (com.android.tools.idea.gradle.dsl.model.values.GradleNotNullValue)7 ExternalNativeBuildOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel)6 NotNull (org.jetbrains.annotations.NotNull)6 NdkOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.NdkOptionsModel)5 CMakeOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel)5