Search in sources :

Example 1 with NdkFacet

use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.

the class DataNodeCaches method isCacheMissingModels.

private static boolean isCacheMissingModels(@NotNull DataNode<ModuleData> cache, @NotNull Module module) {
    GradleFacet gradleFacet = GradleFacet.getInstance(module);
    if (gradleFacet != null) {
        DataNode<GradleModuleModel> gradleDataNode = find(cache, GRADLE_MODULE_MODEL);
        if (gradleDataNode == null) {
            return true;
        }
        AndroidFacet androidFacet = AndroidFacet.getInstance(module);
        if (androidFacet != null) {
            DataNode<AndroidModuleModel> androidDataNode = find(cache, ANDROID_MODEL);
            if (androidDataNode == null || !isValidProxyObject(androidDataNode.getData().getAndroidProject())) {
                return true;
            }
        } else {
            JavaFacet javaFacet = JavaFacet.getInstance(module);
            if (javaFacet != null) {
                DataNode<JavaModuleModel> javaProjectDataNode = find(cache, JAVA_MODULE_MODEL);
                if (javaProjectDataNode == null) {
                    return true;
                }
            }
        }
    }
    NdkFacet ndkFacet = NdkFacet.getInstance(module);
    if (ndkFacet != null) {
        DataNode<NdkModuleModel> ndkModuleModelDataNode = find(cache, NDK_MODEL);
        if (ndkModuleModelDataNode == null || !isValidProxyObject(ndkModuleModelDataNode.getData().getAndroidProject())) {
            return true;
        }
    }
    return false;
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) JavaFacet(com.android.tools.idea.gradle.project.facet.java.JavaFacet) JavaModuleModel(com.android.tools.idea.gradle.project.model.JavaModuleModel) GradleFacet(com.android.tools.idea.gradle.project.facet.gradle.GradleFacet) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 2 with NdkFacet

use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.

the class NdkModuleNode method getChildren.

@NotNull
@Override
public Collection<AbstractTreeNode> getChildren() {
    Module module = getValue();
    if (module == null) {
        return ImmutableList.of();
    }
    NdkFacet facet = NdkFacet.getInstance(module);
    if (facet == null || facet.getNdkModuleModel() == null) {
        return ImmutableList.of();
    }
    return getNativeSourceNodes(myProject, facet.getNdkModuleModel(), getSettings());
}
Also used : NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with NdkFacet

use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.

the class NdkFacetModuleSetupStep method doSetUpModule.

@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull NdkModuleModel ndkModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
    NdkFacet facet = findFacet(module, ideModelsProvider, NdkFacet.getFacetTypeId());
    if (facet != null) {
        configureFacet(facet, ndkModuleModel);
    } else {
        // Module does not have Native Android facet. Create one and add it.
        ModifiableFacetModel model = ideModelsProvider.getModifiableFacetModel(module);
        NdkFacetType facetType = NdkFacet.getFacetType();
        facet = facetType.createFacet(module, NdkFacet.getFacetName(), facetType.createDefaultConfiguration(), null);
        model.addFacet(facet);
        configureFacet(facet, ndkModuleModel);
    }
}
Also used : NdkFacetType(com.android.tools.idea.gradle.project.facet.ndk.NdkFacetType) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)

Example 4 with NdkFacet

use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.

the class BuildVariantUpdater method updateSelectedVariant.

/**
   * Updates a module's structure when the user selects a build variant from the tool window.
   *
   * @param project          the module's project.
   * @param moduleName       the module's name.
   * @param buildVariantName the name of the selected build variant.
   * @return {@code true} if the module update was successful, {@code false} otherwise.
   */
boolean updateSelectedVariant(@NotNull Project project, @NotNull String moduleName, @NotNull String buildVariantName) {
    List<AndroidFacet> affectedAndroidFacets = new ArrayList<>();
    List<NdkFacet> affectedNdkFacets = new ArrayList<>();
    executeProjectChanges(project, () -> {
        Module updatedModule = doUpdate(project, moduleName, buildVariantName, affectedAndroidFacets, affectedNdkFacets);
        if (updatedModule != null) {
            ConflictSet conflicts = findConflicts(project);
            conflicts.showSelectionConflicts();
        }
        PostSyncProjectSetup.Request setupRequest = new PostSyncProjectSetup.Request();
        setupRequest.setGenerateSourcesAfterSync(false).setCleanProjectAfterSync(false);
        PostSyncProjectSetup.getInstance(project).setUpProject(setupRequest, null);
        generateSourcesIfNeeded(affectedAndroidFacets);
    });
    return !affectedAndroidFacets.isEmpty() || !affectedNdkFacets.isEmpty();
}
Also used : PostSyncProjectSetup(com.android.tools.idea.gradle.project.sync.setup.post.PostSyncProjectSetup) ArrayList(java.util.ArrayList) ConflictSet(com.android.tools.idea.gradle.variant.conflict.ConflictSet) NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 5 with NdkFacet

use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.

the class BuildVariantView method updateContents.

public void updateContents() {
    GradleSyncState syncState = GradleSyncState.getInstance(myProject);
    if (syncState.isSyncInProgress() && !syncState.isSyncSkipped()) {
        projectImportStarted();
        return;
    }
    final List<Object[]> rows = Lists.newArrayList();
    final List<BuildVariantItem[]> variantNamesPerRow = Lists.newArrayList();
    for (Module module : getGradleModulesWithAndroidProjects()) {
        AndroidFacet androidFacet = AndroidFacet.getInstance(module);
        NdkFacet ndkFacet = NdkFacet.getInstance(module);
        // getGradleModules() returns only relevant modules.
        assert androidFacet != null || ndkFacet != null;
        String variantName = null;
        if (androidFacet != null) {
            JpsAndroidModuleProperties facetProperties = androidFacet.getProperties();
            variantName = facetProperties.SELECTED_BUILD_VARIANT;
        }
        BuildVariantItem[] variantNames = getVariantItems(module);
        if (variantNames != null) {
            if (androidFacet != null) {
                AndroidModuleModel androidModel = AndroidModuleModel.get(module);
                // AndroidModel may be null when applying a quick fix (e.g. "Fix Gradle version")
                if (androidModel != null) {
                    variantName = androidModel.getSelectedVariant().getName();
                }
            } else {
                // As only the modules backed by either AndroidGradleModel or NativeAndroidGradleModel are shown in the Build Variants View,
                // when a module is not backed by AndroidGradleModel, it surely contains a valid NativeAndroidGradleModel.
                NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
                if (ndkModuleModel != null) {
                    variantName = ndkModuleModel.getSelectedVariant().getName();
                }
            }
            variantNamesPerRow.add(variantNames);
        }
        if (variantName != null) {
            Object[] row = { module, variantName };
            rows.add(row);
        }
    }
    Runnable setModelTask = () -> getVariantsTable().setModel(rows, variantNamesPerRow);
    Application application = ApplicationManager.getApplication();
    if (application.isDispatchThread()) {
        setModelTask.run();
    } else {
        application.invokeLater(setModelTask);
    }
}
Also used : NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet) JpsAndroidModuleProperties(org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) Module(com.intellij.openapi.module.Module) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) Application(com.intellij.openapi.application.Application)

Aggregations

NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)10 Module (com.intellij.openapi.module.Module)7 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)6 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)4 NotNull (org.jetbrains.annotations.NotNull)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)3 NdkFacetType (com.android.tools.idea.gradle.project.facet.ndk.NdkFacetType)2 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)2 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)1 JavaFacet (com.android.tools.idea.gradle.project.facet.java.JavaFacet)1 GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)1 JavaModuleModel (com.android.tools.idea.gradle.project.model.JavaModuleModel)1 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)1 PostSyncProjectSetup (com.android.tools.idea.gradle.project.sync.setup.post.PostSyncProjectSetup)1 ConflictSet (com.android.tools.idea.gradle.variant.conflict.ConflictSet)1 ViewSettings (com.intellij.ide.projectView.ViewSettings)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 Application (com.intellij.openapi.application.Application)1 Project (com.intellij.openapi.project.Project)1