Search in sources :

Example 1 with NdkBuildModel

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

the class ExternalNativeBuildModel method ndkBuild.

@NotNull
public NdkBuildModel ndkBuild() {
    NdkBuildDslElement ndkBuildDslElement = myDslElement.getPropertyElement(NDK_BUILD_BLOCK_NAME, NdkBuildDslElement.class);
    if (ndkBuildDslElement == null) {
        ndkBuildDslElement = new NdkBuildDslElement(myDslElement);
        myDslElement.setNewElement(NDK_BUILD_BLOCK_NAME, ndkBuildDslElement);
    }
    return new NdkBuildModel(ndkBuildDslElement);
}
Also used : NdkBuildDslElement(com.android.tools.idea.gradle.dsl.parser.android.externalNativeBuild.NdkBuildDslElement) NdkBuildModel(com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.NdkBuildModel) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with NdkBuildModel

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

the class ExternalNativeBuildModelTest method testAddNdkBuildPathAndReset.

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

Example 3 with NdkBuildModel

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

the class ExternalNativeBuildModelTest method testNdkBuildWithNewFilePath.

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

Example 4 with NdkBuildModel

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

the class ExternalNativeBuildModelTest method testAddNdkBuildPathAndApplyChanges.

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

Example 5 with NdkBuildModel

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

the class ExternalNativeBuildModelTest method testNdkBuild.

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

Aggregations

NdkBuildModel (com.android.tools.idea.gradle.dsl.model.android.externalNativeBuild.NdkBuildModel)5 File (java.io.File)4 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)2 NdkBuildDslElement (com.android.tools.idea.gradle.dsl.parser.android.externalNativeBuild.NdkBuildDslElement)1 NotNull (org.jetbrains.annotations.NotNull)1