Search in sources :

Example 6 with ExternalSystemTaskNotificationListenerAdapter

use of com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter in project freeline by alibaba.

the class UpdateAction method updateAction.

/**
 * 更新操作
 *
 * @param newVersion
 * @param gradleBuildModels
 */
protected void updateAction(final String newVersion, final Map<GradleBuildModel, List<ArtifactDependencyModel>> gradleBuildModels) {
    CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {

        @Override
        public void run() {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {

                @Override
                public void run() {
                    for (GradleBuildModel file : gradleBuildModels.keySet()) {
                        List<ArtifactDependencyModel> models = gradleBuildModels.get(file);
                        for (ArtifactDependencyModel dependencyModel1 : models) {
                            ArtifactDependencyModelWrapper dependencyModel = new ArtifactDependencyModelWrapper(dependencyModel1);
                            if (isClasspathLibrary(dependencyModel)) {
                                dependencyModel1.setVersion(newVersion);
                            }
                            if (isDependencyLibrary(dependencyModel)) {
                                file.dependencies().remove(dependencyModel1);
                            }
                        }
                        file.applyChanges();
                    }
                    GradleUtil.executeTask(currentProject, "initFreeline", "-Pmirror", new ExternalSystemTaskNotificationListenerAdapter() {

                        @Override
                        public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
                            super.onTaskOutput(id, text, stdOut);
                        }
                    });
                }
            });
        }
    });
}
Also used : ExternalSystemTaskId(com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ArtifactDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel) ExternalSystemTaskNotificationListenerAdapter(com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter) ArtifactDependencyModelWrapper(com.antfortune.freeline.idea.models.ArtifactDependencyModelWrapper)

Aggregations

ExternalSystemTaskNotificationListenerAdapter (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter)6 ExternalSystemTaskId (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId)5 NotNull (org.jetbrains.annotations.NotNull)3 ExternalSystemTaskNotificationListener (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener)2 ExternalSystemProgressNotificationManager (com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager)2 AndroidProject (com.android.builder.model.AndroidProject)1 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)1 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 ArtifactDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel)1 CommandLineArgs (com.android.tools.idea.gradle.project.sync.common.CommandLineArgs)1 IdeaProjectStub (com.android.tools.idea.gradle.stubs.gradle.IdeaProjectStub)1 AndroidGradleTaskManager (com.android.tools.idea.gradle.task.AndroidGradleTaskManager)1 GRADLE_SYSTEM_ID (com.android.tools.idea.gradle.util.GradleUtil.GRADLE_SYSTEM_ID)1 GradleUtil.getOrCreateGradleExecutionSettings (com.android.tools.idea.gradle.util.GradleUtil.getOrCreateGradleExecutionSettings)1 Projects.getBaseDirPath (com.android.tools.idea.gradle.util.Projects.getBaseDirPath)1 ArtifactDependencyModelWrapper (com.antfortune.freeline.idea.models.ArtifactDependencyModelWrapper)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Lists (com.google.common.collect.Lists)1 DuplexConsoleView (com.intellij.execution.console.DuplexConsoleView)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1