Search in sources :

Example 1 with ExternalSystemExecutionSettings

use of com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings in project intellij-community by JetBrains.

the class ExternalSystemFacadeManager method doCreateFacade.

@SuppressWarnings("unchecked")
@NotNull
private RemoteExternalSystemFacade doCreateFacade(@NotNull IntegrationKey key, @NotNull Project project, @NotNull ExternalSystemCommunicationManager communicationManager) throws Exception {
    final RemoteExternalSystemFacade facade = communicationManager.acquire(key.getExternalProjectConfigPath(), key.getExternalSystemId());
    if (facade == null) {
        throw new IllegalStateException("Can't obtain facade to working with external api at the remote process. Project: " + project);
    }
    Disposer.register(project, new Disposable() {

        @Override
        public void dispose() {
            myFacadeWrappers.clear();
            myRemoteFacades.clear();
        }
    });
    final RemoteExternalSystemFacade result = new ExternalSystemFacadeWrapper(facade, myProgressManager);
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(project, key.getExternalProjectConfigPath(), key.getExternalSystemId());
    Pair<RemoteExternalSystemFacade, ExternalSystemExecutionSettings> newPair = Pair.create(result, settings);
    myRemoteFacades.put(key, newPair);
    result.applySettings(newPair.second);
    return result;
}
Also used : Disposable(com.intellij.openapi.Disposable) ExternalSystemFacadeWrapper(com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemFacadeWrapper) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ExternalSystemExecutionSettings

use of com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings in project intellij-community by JetBrains.

the class ExternalSystemFacadeManager method doGetFacade.

@SuppressWarnings("ConstantConditions")
@NotNull
private RemoteExternalSystemFacade doGetFacade(@NotNull IntegrationKey key, @NotNull Project project) throws Exception {
    final boolean currentInProcess = ExternalSystemApiUtil.isInProcessMode(key.getExternalSystemId());
    final ExternalSystemCommunicationManager myCommunicationManager = currentInProcess ? myInProcessCommunicationManager : myRemoteCommunicationManager;
    ExternalSystemManager manager = ExternalSystemApiUtil.getManager(key.getExternalSystemId());
    if (project.isDisposed() || manager == null) {
        return RemoteExternalSystemFacade.NULL_OBJECT;
    }
    Pair<RemoteExternalSystemFacade, ExternalSystemExecutionSettings> pair = myRemoteFacades.get(key);
    if (pair != null && prepare(myCommunicationManager, project, key, pair)) {
        return pair.first;
    }
    myLock.lock();
    try {
        pair = myRemoteFacades.get(key);
        if (pair != null && prepare(myCommunicationManager, project, key, pair)) {
            return pair.first;
        }
        if (pair != null) {
            myFacadeWrappers.clear();
            myRemoteFacades.clear();
        }
        return doCreateFacade(key, project, myCommunicationManager);
    } finally {
        myLock.unlock();
    }
}
Also used : ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ExternalSystemExecutionSettings

use of com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings in project intellij-community by JetBrains.

the class ExternalSystemFacadeManager method prepare.

@SuppressWarnings("unchecked")
private boolean prepare(@NotNull ExternalSystemCommunicationManager communicationManager, @NotNull Project project, @NotNull IntegrationKey key, @NotNull Pair<RemoteExternalSystemFacade, ExternalSystemExecutionSettings> pair) {
    if (!communicationManager.isAlive(pair.first)) {
        return false;
    }
    try {
        ExternalSystemExecutionSettings currentSettings = ExternalSystemApiUtil.getExecutionSettings(project, key.getExternalProjectConfigPath(), key.getExternalSystemId());
        if (!currentSettings.equals(pair.second)) {
            pair.first.applySettings(currentSettings);
            myRemoteFacades.put(key, Pair.create(pair.first, currentSettings));
        }
        return true;
    } catch (RemoteException e) {
        return false;
    }
}
Also used : RemoteException(java.rmi.RemoteException) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings)

Example 4 with ExternalSystemExecutionSettings

use of com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings in project intellij-community by JetBrains.

the class ExternalSystemExecuteTaskTask method doExecute.

@SuppressWarnings("unchecked")
@Override
protected void doExecute() throws Exception {
    final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(getIdeProject(), getExternalProjectPath(), getExternalSystemId());
    KeyFMap keyFMap = getUserMap();
    for (Key key : keyFMap.getKeys()) {
        settings.putUserData(key, keyFMap.get(key));
    }
    RemoteExternalSystemFacade facade = manager.getFacade(getIdeProject(), getExternalProjectPath(), getExternalSystemId());
    RemoteExternalSystemTaskManager taskManager = facade.getTaskManager();
    List<String> taskNames = ContainerUtilRt.map2List(myTasksToExecute, ExternalTaskPojo::getName);
    final List<String> vmOptions = parseCmdParameters(myVmOptions);
    final List<String> arguments = parseCmdParameters(myArguments);
    settings.withVmOptions(vmOptions).withArguments(arguments);
    taskManager.executeTasks(getId(), taskNames, getExternalProjectPath(), settings, myJvmAgentSetup);
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) KeyFMap(com.intellij.util.keyFMap.KeyFMap) RemoteExternalSystemTaskManager(com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager) ExternalSystemFacadeManager(com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager) RemoteExternalSystemFacade(com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) Key(com.intellij.openapi.util.Key)

Example 5 with ExternalSystemExecutionSettings

use of com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings in project intellij-community by JetBrains.

the class ExternalSystemResolveProjectTask method doExecute.

@SuppressWarnings("unchecked")
protected void doExecute() throws Exception {
    final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    Project ideProject = getIdeProject();
    RemoteExternalSystemProjectResolver resolver = manager.getFacade(ideProject, myProjectPath, getExternalSystemId()).getResolver();
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(ideProject, myProjectPath, getExternalSystemId());
    if (StringUtil.isNotEmpty(myVmOptions)) {
        settings.withVmOptions(ParametersListUtil.parse(myVmOptions));
    }
    if (StringUtil.isNotEmpty(myArguments)) {
        settings.withArguments(ParametersListUtil.parse(myArguments));
    }
    ExternalSystemProgressNotificationManagerImpl progressNotificationManager = (ExternalSystemProgressNotificationManagerImpl) ServiceManager.getService(ExternalSystemProgressNotificationManager.class);
    ExternalSystemTaskId id = getId();
    progressNotificationManager.onStart(id, myProjectPath);
    try {
        DataNode<ProjectData> project = resolver.resolveProjectInfo(id, myProjectPath, myIsPreviewMode, settings);
        if (project != null) {
            myExternalProject.set(project);
            ExternalSystemManager<?, ?, ?, ?, ?> systemManager = ExternalSystemApiUtil.getManager(getExternalSystemId());
            assert systemManager != null;
            Set<String> externalModulePaths = ContainerUtil.newHashSet();
            Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(project, ProjectKeys.MODULE);
            for (DataNode<ModuleData> node : moduleNodes) {
                externalModulePaths.add(node.getData().getLinkedExternalProjectPath());
            }
            String projectPath = project.getData().getLinkedExternalProjectPath();
            ExternalProjectSettings linkedProjectSettings = systemManager.getSettingsProvider().fun(ideProject).getLinkedProjectSettings(projectPath);
            if (linkedProjectSettings != null) {
                linkedProjectSettings.setModules(externalModulePaths);
            }
        }
        progressNotificationManager.onSuccess(id);
    } finally {
        progressNotificationManager.onEnd(id);
    }
}
Also used : ExternalSystemTaskId(com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId) ExternalSystemProgressNotificationManagerImpl(com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl) ExternalSystemFacadeManager(com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager) ExternalSystemProgressNotificationManager(com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) Project(com.intellij.openapi.project.Project) RemoteExternalSystemProjectResolver(com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Aggregations

ExternalSystemExecutionSettings (com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings)5 ExternalSystemFacadeManager (com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager)2 NotNull (org.jetbrains.annotations.NotNull)2 Disposable (com.intellij.openapi.Disposable)1 ExternalSystemManager (com.intellij.openapi.externalSystem.ExternalSystemManager)1 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 ExternalTaskPojo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)1 ExternalSystemTaskId (com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId)1 RemoteExternalSystemFacade (com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade)1 ExternalSystemProgressNotificationManager (com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager)1 ExternalSystemProgressNotificationManagerImpl (com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl)1 RemoteExternalSystemProjectResolver (com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver)1 RemoteExternalSystemTaskManager (com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager)1 ExternalSystemFacadeWrapper (com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemFacadeWrapper)1 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)1 Project (com.intellij.openapi.project.Project)1 Key (com.intellij.openapi.util.Key)1 KeyFMap (com.intellij.util.keyFMap.KeyFMap)1