Search in sources :

Example 1 with CMakeModel

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

the class ExternalNativeBuildModel method cmake.

@NotNull
public CMakeModel cmake() {
    CMakeDslElement cMakeDslElement = myDslElement.getPropertyElement(CMAKE_BLOCK_NAME, CMakeDslElement.class);
    if (cMakeDslElement == null) {
        cMakeDslElement = new CMakeDslElement(myDslElement);
        myDslElement.setNewElement(CMAKE_BLOCK_NAME, cMakeDslElement);
    }
    return new CMakeModel(cMakeDslElement);
}
Also used : CMakeDslElement(com.android.tools.idea.gradle.dsl.parser.android.externalNativeBuild.CMakeDslElement) CMakeModel(com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.CMakeModel) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with CMakeModel

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

the class AndroidModelTest method testAndroidBlockWithExternalNativeBuildBlock.

public void testAndroidBlockWithExternalNativeBuildBlock() throws Exception {
    String text = "android {\n" + "  externalNativeBuild {\n" + "    cmake {\n" + "      path file(\"foo/bar\")\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    ExternalNativeBuildModel externalNativeBuild = android.externalNativeBuild();
    assertTrue(externalNativeBuild.hasValidPsiElement());
    CMakeModel cmake = externalNativeBuild.cmake();
    assertTrue(cmake.hasValidPsiElement());
    assertEquals("path", new File("foo/bar"), cmake.path());
}
Also used : CMakeModel(com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.CMakeModel) File(java.io.File)

Example 3 with CMakeModel

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

the class ExternalNativeBuildModelTest method testAddCMakePathAndReset.

public void testAddCMakePathAndReset() throws Exception {
    String text = "android {\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    ExternalNativeBuildModel externalNativeBuild = android.externalNativeBuild();
    CMakeModel cmake = externalNativeBuild.cmake();
    assertNull(cmake.path());
    cmake.setPath(new File("foo/bar"));
    assertEquals("path", new File("foo/bar"), cmake.path());
    buildModel.resetState();
    assertNull(cmake.path());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) CMakeModel(com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.CMakeModel) File(java.io.File)

Example 4 with CMakeModel

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

the class ExternalNativeBuildModelTest method testAddCMakePathAndApplyChanges.

public void testAddCMakePathAndApplyChanges() throws Exception {
    String text = "android {\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    CMakeModel cmake = android.externalNativeBuild().cmake();
    assertNull(cmake.path());
    cmake.setPath(new File("foo/bar"));
    assertEquals("path", new File("foo/bar"), cmake.path());
    applyChanges(buildModel);
    assertEquals("path", new File("foo/bar"), cmake.path());
    buildModel.reparse();
    android = buildModel.android();
    assertNotNull(android);
    cmake = android.externalNativeBuild().cmake();
    assertEquals("path", new File("foo/bar"), cmake.path());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) CMakeModel(com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.CMakeModel) File(java.io.File)

Example 5 with CMakeModel

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

the class ExternalNativeBuildModelTest method testCMakeWithNewFilePath.

public void testCMakeWithNewFilePath() throws Exception {
    String text = "android {\n" + "  externalNativeBuild {\n" + "    cmake {\n" + "      path new File(\"foo/bar\")\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    ExternalNativeBuildModel externalNativeBuild = android.externalNativeBuild();
    assertTrue(externalNativeBuild.hasValidPsiElement());
    CMakeModel cmake = externalNativeBuild.cmake();
    assertTrue(cmake.hasValidPsiElement());
    assertEquals("path", new File("foo/bar"), cmake.path());
}
Also used : CMakeModel(com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.CMakeModel) File(java.io.File)

Aggregations

CMakeModel (com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.CMakeModel)6 File (java.io.File)5 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)2 CMakeDslElement (com.android.tools.idea.gradle.dsl.parser.android.externalNativeBuild.CMakeDslElement)1 NotNull (org.jetbrains.annotations.NotNull)1