com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId Java Examples

The following examples show how to use com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteExternalSystemTaskManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void executeTasks(@Nonnull final ExternalSystemTaskId id,
                         @Nonnull final List<String> taskNames,
                         @Nonnull final String projectPath,
                         @Nullable final S settings,
                         @Nonnull final List<String> vmOptions,
                         @Nonnull final List<String> scriptParameters,
                         @Nullable final String debuggerSetup) throws RemoteException, ExternalSystemException
{
  execute(id, new Producer<Object>() {
    @Nullable
    @Override
    public Object produce() {
      myDelegate.executeTasks(
              id, taskNames, projectPath, settings, vmOptions, scriptParameters, debuggerSetup, getNotificationListener());
      return null;
    }
  });
}
 
Example #2
Source File: RemoteExternalSystemProjectResolverImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@javax.annotation.Nullable
@Override
public DataNode<ProjectData> resolveProjectInfo(@Nonnull final ExternalSystemTaskId id,
                                                @Nonnull final String projectPath,
                                                final boolean isPreviewMode,
                                                ExternalSystemExecutionSettings settings)
  throws ExternalSystemException, IllegalArgumentException, IllegalStateException
{
  return execute(id, new Producer<DataNode<ProjectData>>() {
    @javax.annotation.Nullable
    @Override
    public DataNode<ProjectData> produce() {
      return myDelegate.resolveProjectInfo(id, projectPath, isPreviewMode, getSettings(), getNotificationListener());
    }
  });
}
 
Example #3
Source File: ExternalSystemFacadeManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean isTaskActive(@Nonnull ExternalSystemTaskId id) {
  Map<IntegrationKey, Pair<RemoteExternalSystemFacade, ExternalSystemExecutionSettings>> copy
    = ContainerUtilRt.newHashMap(myRemoteFacades);
  for (Map.Entry<IntegrationKey, Pair<RemoteExternalSystemFacade, ExternalSystemExecutionSettings>> entry : copy.entrySet()) {
    try {
      if (entry.getValue().first.isTaskInProgress(id)) {
        return true;
      }
    }
    catch (RemoteException e) {
      myLock.lock();
      try {
        myRemoteFacades.remove(entry.getKey());
        myFacadeWrappers.remove(entry.getKey());
      }
      finally {
        myLock.unlock();
      }
    }
  }
  return false;
}
 
Example #4
Source File: ExternalSystemRunConfiguration.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void detachProcessImpl() {
  myTask.cancel(new ExternalSystemTaskNotificationListenerAdapter() {

    private boolean myResetGreeting = true;

    @Override
    public void onTaskOutput(@Nonnull ExternalSystemTaskId id, @Nonnull String text, boolean stdOut) {
      if (myResetGreeting) {
        notifyTextAvailable("\r", ProcessOutputTypes.SYSTEM);
        myResetGreeting = false;
      }
      notifyTextAvailable(text, stdOut ? ProcessOutputTypes.STDOUT : ProcessOutputTypes.STDERR);
    }
  });
  notifyProcessDetached();
}
 
Example #5
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private void doViewSwitch(@NotNull ExternalSystemTaskId id, @NotNull String projectPath) {
  Project ideProject = id.findProject();
  if (ideProject == null) {
    return;
  }
  // Disable zooming on subsequent project resolves/refreshes,
  // i.e. a project that already has existing modules, because it may zoom at a module
  // that is going to be replaced by the current resolve.
  if (ModuleManager.getInstance(ideProject).getModules().length > 0) {
    return;
  }

  MessageBusConnection messageBusConnection = ideProject.getMessageBus().connect();
  messageBusConnection.subscribe(
    ProjectTopics.PROJECT_ROOTS,
    new ModuleRootListener() {
      @Override
      public void rootsChanged(ModuleRootEvent event) {
        // Initiate view switch only when project modules have been created.
        new ViewSwitchProcessor(ideProject, projectPath).asyncViewSwitch();
      }
    }
  );
}
 
Example #6
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Check whether the pants executable of the new project to import is the same as the existing project's pants executable.
 */
private void checkForDifferentPantsExecutables(@NotNull ExternalSystemTaskId id, @NotNull String projectPath) {
  final Project existingIdeProject = id.findProject();
  if (existingIdeProject == null) {
    return;
  }
  String projectFilePath = existingIdeProject.getProjectFilePath();
  if (projectFilePath == null) {
    return;
  }
  final Optional<VirtualFile> existingPantsExe = PantsUtil.findPantsExecutable(projectFilePath);
  final Optional<VirtualFile> newPantsExe = PantsUtil.findPantsExecutable(projectPath);
  if (!existingPantsExe.isPresent() || !newPantsExe.isPresent()) {
    return;
  }
  if (!existingPantsExe.get().getCanonicalFile().getPath().equals(newPantsExe.get().getCanonicalFile().getPath())) {
    throw new ExternalSystemException(String.format(
      "Failed to import. Target/Directory to be added uses a different pants executable %s compared to the existing project's %s",
      existingPantsExe, newPantsExe
    ));
  }
}
 
Example #7
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private void resolveUsingPantsGoal(
  @NotNull final ExternalSystemTaskId id,
  @NotNull PantsCompileOptionsExecutor executor,
  final ExternalSystemTaskNotificationListener listener,
  @NotNull DataNode<ProjectData> projectDataNode
) {
  final PantsResolver dependenciesResolver = new PantsResolver(executor);
  dependenciesResolver.resolve(
    status -> listener.onStatusChange(new ExternalSystemTaskNotificationEvent(id, status)),
    new ProcessAdapter() {
      @Override
      public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
        listener.onTaskOutput(id, event.getText(), outputType == ProcessOutputTypes.STDOUT);
      }
    }
  );
  dependenciesResolver.addInfoTo(projectDataNode);
}
 
Example #8
Source File: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public DataNode<ProjectData> resolveProjectInfo(
  @NotNull ExternalSystemTaskId id,
  @NotNull String projectPath,
  boolean isPreviewMode,
  @Nullable PantsExecutionSettings settings,
  @NotNull ExternalSystemTaskNotificationListener listener
) throws ExternalSystemException, IllegalArgumentException, IllegalStateException {
  if (projectPath.startsWith(".pants.d")) {
    return null;
  }

  checkForDifferentPantsExecutables(id, projectPath);
  final PantsCompileOptionsExecutor executor = PantsCompileOptionsExecutor.create(projectPath, settings);
  task2executor.put(id, executor);

  final DataNode<ProjectData> projectDataNode =
    resolveProjectInfoImpl(id, executor, listener, settings, isPreviewMode);

  // We do not want to repeatedly force switching to 'Project Files Tree' view if
  // user decides to use import dep as jar and wants to use the more focused 'Project' view.
  if (!settings.isImportSourceDepsAsJars()) {
    doViewSwitch(id, projectPath);
  }
  task2executor.remove(id);
  // Removing the existing modules right before returning to minimize the time user observes
  // that the old modules are gone.
  Optional.ofNullable(id.findProject()).ifPresent(p -> clearPantsModules(p, projectPath, projectDataNode));
  return projectDataNode;
}
 
Example #9
Source File: AbstractRemoteExternalSystemService.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected <T> T execute(@Nonnull ExternalSystemTaskId id, @Nonnull Producer<T> task) {
  Set<ExternalSystemTaskId> tasks = myTasksInProgress.get(id.getType());
  if (tasks == null) {
    myTasksInProgress.putIfAbsent(id.getType(), new HashSet<ExternalSystemTaskId>());
    tasks = myTasksInProgress.get(id.getType());
  }
  tasks.add(id);
  try {
    return task.produce();
  }
  finally {
    tasks.remove(id);
  }
}
 
Example #10
Source File: PantsProjectImportNotificationListener.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void onEnd(@NotNull ExternalSystemTaskId id) {
  Project project = id.findProject();
  if (project == null) {
    return;
  }
  PantsMetrics.markResolveEnd();
  PantsMetrics.prepareTimeIndexing(project);
  // Sync files as generated sources may have changed after `pants export` called
  // due to import and refresh.
  PantsUtil.synchronizeFiles();
  super.onEnd(id);
}
 
Example #11
Source File: AbstractExternalSystemTaskManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public abstract void executeTasks(@Nonnull ExternalSystemTaskId id,
@Nonnull List<String> taskNames,
@Nonnull String projectPath,
@Nullable S settings,
@Nonnull final List<String> vmOptions,
@Nonnull List<String> scriptParameters,
@Nullable String debuggerSetup,
@Nonnull ExternalSystemTaskNotificationListener listener) throws ExternalSystemException;
 
Example #12
Source File: UpdateAction.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 更新操作
 *
 * @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);
                        }
                    });
                }
            });
        }
    });
}
 
Example #13
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onEnd(@Nonnull ExternalSystemTaskId id) {
  for (Map.Entry<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>> entry : myListeners.entrySet()) {
    final Set<ExternalSystemTaskId> ids = entry.getValue();
    if (Collections.EMPTY_SET == ids || ids.contains(id)) {
      entry.getKey().onEnd(id);
    }
  } 
}
 
Example #14
Source File: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 执行./gradlew initFreeline
 * @param project
 */
public static void initFreeline(Project project) {
    GradleUtil.executeTask(project, "initFreeline", "-Pmirror", new ExternalSystemTaskNotificationListenerAdapter() {
        @Override
        public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
            super.onTaskOutput(id, text, stdOut);
        }
    });
}
 
Example #15
Source File: FlutterExternalSystemTaskNotificationListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onSuccess(@NotNull ExternalSystemTaskId id) {
  if (id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT && id.getProjectSystemId() == GradleConstants.SYSTEM_ID) {
    Project project = id.findProject();
    if (project != null) {
      AndroidUtils.checkDartSupport(project);
    }
  }
}
 
Example #16
Source File: PantsProjectImportNotificationListener.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart(@NotNull ExternalSystemTaskId id, String workingDir) {
  super.onStart(id, workingDir);
  if (id.findProject() == null) {
    return;
  }
  PantsMetrics.markResolveStart();
}
 
Example #17
Source File: FlutterExternalSystemTaskNotificationListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onSuccess(@NotNull ExternalSystemTaskId id) {
  if (id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT && id.getProjectSystemId() == GradleConstants.SYSTEM_ID) {
    Project project = id.findProject();
    if (project != null) {
      AndroidUtils.checkDartSupport(project);
    }
  }
}
 
Example #18
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 执行./gradlew assembleRelease
 * @param project
 */
public static void buildAndroid(Project project) {
    GradleUtil.executeTask(project, "assembleRelease", "-Pmirror", new ExternalSystemTaskNotificationListenerAdapter() {
        @Override
        public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
            super.onTaskOutput(id, text, stdOut);
        }
    });
}
 
Example #19
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onFailure(@Nonnull ExternalSystemTaskId id, @Nonnull Exception e) throws RemoteException {
  for (Map.Entry<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>> entry : myListeners.entrySet()) {
    final Set<ExternalSystemTaskId> ids = entry.getValue();
    if (Collections.EMPTY_SET == ids || ids.contains(id)) {
      entry.getKey().onFailure(id, e);
    }
  }
}
 
Example #20
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(@Nonnull ExternalSystemTaskId id) throws RemoteException {
  for (Map.Entry<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>> entry : myListeners.entrySet()) {
    final Set<ExternalSystemTaskId> ids = entry.getValue();
    if (Collections.EMPTY_SET == ids || ids.contains(id)) {
      entry.getKey().onSuccess(id);
    }
  }
}
 
Example #21
Source File: RemoteExternalSystemTaskManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void executeTasks(@Nonnull ExternalSystemTaskId id,
                         @Nonnull List<String> taskNames,
                         @Nonnull String projectPath,
                         @javax.annotation.Nullable ExternalSystemExecutionSettings settings,
                         @Nonnull List<String> vmOptions,
                         @Nonnull List<String> scriptParameters,
                         @javax.annotation.Nullable String debuggerSetup) throws RemoteException, ExternalSystemException
{
}
 
Example #22
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onTaskOutput(@Nonnull ExternalSystemTaskId id, @Nonnull String text, boolean stdOut) throws RemoteException {
  for (Map.Entry<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>> entry : myListeners.entrySet()) {
    final Set<ExternalSystemTaskId> ids = entry.getValue();
    if (Collections.EMPTY_SET == ids || ids.contains(id)) {
      entry.getKey().onTaskOutput(id, text, stdOut);
    }
  }
}
 
Example #23
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStatusChange(@Nonnull ExternalSystemTaskNotificationEvent event) {
  for (Map.Entry<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>> entry : myListeners.entrySet()) {
    final Set<ExternalSystemTaskId> ids = entry.getValue();
    if (Collections.EMPTY_SET == ids || ids.contains(event.getId())) {
      entry.getKey().onStatusChange(event);
    }
  } 
}
 
Example #24
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart(@Nonnull ExternalSystemTaskId id) {
  for (Map.Entry<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>> entry : myListeners.entrySet()) {
    final Set<ExternalSystemTaskId> ids = entry.getValue();
    if (Collections.EMPTY_SET == ids || ids.contains(id)) {
      entry.getKey().onStart(id);
    }
  } 
}
 
Example #25
Source File: RemoteExternalSystemTaskManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
void executeTasks(@Nonnull ExternalSystemTaskId id,
@Nonnull List<String> taskNames,
@Nonnull String projectPath,
@Nullable S settings,
@Nonnull List<String> vmOptions,
@Nonnull List<String> scriptParameters,
@javax.annotation.Nullable String debuggerSetup) throws RemoteException, ExternalSystemException;
 
Example #26
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onQueued(@Nonnull ExternalSystemTaskId id) {
  for (Map.Entry<ExternalSystemTaskNotificationListener, Set<ExternalSystemTaskId>> entry : myListeners.entrySet()) {
    final Set<ExternalSystemTaskId> ids = entry.getValue();
    if (Collections.EMPTY_SET == ids || ids.contains(id)) {
      entry.getKey().onQueued(id);
    }
  }

}
 
Example #27
Source File: ExternalSystemProgressNotificationManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean addNotificationListener(@Nonnull ExternalSystemTaskId taskId, @Nonnull ExternalSystemTaskNotificationListener listener) {
  Set<ExternalSystemTaskId> ids = null;
  while (ids == null) {
    if (myListeners.containsKey(listener)) {
      ids = myListeners.get(listener);
    }
    else {
      ids = myListeners.putIfAbsent(listener, ContainerUtil.newConcurrentSet());
    }
  }
  return ids.add(taskId);
}
 
Example #28
Source File: ExternalSystemProjectResolverWrapper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean cancelTask(@Nonnull ExternalSystemTaskId id)
  throws ExternalSystemException, IllegalArgumentException, IllegalStateException, RemoteException {
  myProgressManager.onQueued(id);
  try {
    return getDelegate().cancelTask(id);
  }
  finally {
    myProgressManager.onEnd(id);
  }
}
 
Example #29
Source File: ExternalSystemTaskManagerWrapper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean cancelTask(@Nonnull ExternalSystemTaskId id) throws RemoteException, ExternalSystemException
{
  myProgressManager.onQueued(id);
  try {
    return getDelegate().cancelTask(id);
  }
  finally {
    myProgressManager.onEnd(id);
  }
}
 
Example #30
Source File: RemoteExternalSystemProjectResolver.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
@Override
public DataNode<ProjectData> resolveProjectInfo(@Nonnull ExternalSystemTaskId id,
                                                @Nonnull String projectPath,
                                                boolean isPreviewMode,
                                                @javax.annotation.Nullable ExternalSystemExecutionSettings settings)
  throws ExternalSystemException, IllegalArgumentException, IllegalStateException
{
  return null;
}