Search in sources :

Example 1 with ConflictSet

use of com.android.tools.idea.gradle.variant.conflict.ConflictSet 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 2 with ConflictSet

use of com.android.tools.idea.gradle.variant.conflict.ConflictSet in project android by JetBrains.

the class PostSyncProjectSetup method findAndShowVariantConflicts.

private void findAndShowVariantConflicts() {
    ConflictSet conflicts = findConflicts(myProject);
    List<Conflict> structureConflicts = conflicts.getStructureConflicts();
    if (!structureConflicts.isEmpty() && SystemProperties.getBooleanProperty("enable.project.profiles", false)) {
        ProjectProfileSelectionDialog dialog = new ProjectProfileSelectionDialog(myProject, structureConflicts);
        dialog.show();
    }
    List<Conflict> selectionConflicts = conflicts.getSelectionConflicts();
    if (!selectionConflicts.isEmpty()) {
        boolean atLeastOneSolved = solveSelectionConflicts(selectionConflicts);
        if (atLeastOneSolved) {
            conflicts = findConflicts(myProject);
        }
    }
    conflicts.showSelectionConflicts();
}
Also used : Conflict(com.android.tools.idea.gradle.variant.conflict.Conflict) ConflictSet(com.android.tools.idea.gradle.variant.conflict.ConflictSet) ProjectProfileSelectionDialog(com.android.tools.idea.gradle.variant.profiles.ProjectProfileSelectionDialog)

Aggregations

ConflictSet (com.android.tools.idea.gradle.variant.conflict.ConflictSet)2 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)1 PostSyncProjectSetup (com.android.tools.idea.gradle.project.sync.setup.post.PostSyncProjectSetup)1 Conflict (com.android.tools.idea.gradle.variant.conflict.Conflict)1 ProjectProfileSelectionDialog (com.android.tools.idea.gradle.variant.profiles.ProjectProfileSelectionDialog)1 Module (com.intellij.openapi.module.Module)1 ArrayList (java.util.ArrayList)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1