Search in sources :

Example 1 with ExternalTaskPojo

use of com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo in project intellij-community by JetBrains.

the class ExternalSystemBeforeRunTaskProvider method executeTask.

@Override
public boolean executeTask(DataContext context, RunConfiguration configuration, ExecutionEnvironment env, ExternalSystemBeforeRunTask beforeRunTask) {
    final ExternalSystemTaskExecutionSettings executionSettings = beforeRunTask.getTaskExecutionSettings();
    final List<ExternalTaskPojo> tasks = ContainerUtilRt.newArrayList();
    for (String taskName : executionSettings.getTaskNames()) {
        tasks.add(new ExternalTaskPojo(taskName, executionSettings.getExternalProjectPath(), null));
    }
    if (tasks.isEmpty())
        return true;
    ExecutionEnvironment environment = ExternalSystemUtil.createExecutionEnvironment(myProject, mySystemId, executionSettings, DefaultRunExecutor.EXECUTOR_ID);
    if (environment == null)
        return false;
    final ProgramRunner runner = environment.getRunner();
    environment.setExecutionId(env.getExecutionId());
    return RunConfigurationBeforeRunProvider.doRunTask(DefaultRunExecutor.getRunExecutorInstance().getId(), environment, runner);
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ProgramRunner(com.intellij.execution.runners.ProgramRunner) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)

Example 2 with ExternalTaskPojo

use of com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo in project intellij-community by JetBrains.

the class GradleManager method patchAvailableTasks.

private static void patchAvailableTasks(@NotNull Map<String, String> adjustedPaths, @NotNull GradleLocalSettings localSettings) {
    Map<String, Collection<ExternalTaskPojo>> adjustedAvailableTasks = ContainerUtilRt.newHashMap();
    for (Map.Entry<String, Collection<ExternalTaskPojo>> entry : localSettings.getAvailableTasks().entrySet()) {
        String newPath = adjustedPaths.get(entry.getKey());
        if (newPath == null) {
            adjustedAvailableTasks.put(entry.getKey(), entry.getValue());
        } else {
            for (ExternalTaskPojo task : entry.getValue()) {
                String newTaskPath = adjustedPaths.get(task.getLinkedExternalProjectPath());
                if (newTaskPath != null) {
                    task.setLinkedExternalProjectPath(newTaskPath);
                }
            }
            adjustedAvailableTasks.put(newPath, entry.getValue());
        }
    }
    localSettings.setAvailableTasks(adjustedAvailableTasks);
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo)

Example 3 with ExternalTaskPojo

use of com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo in project intellij-community by JetBrains.

the class ExternalProjectsDataStorage method convert.

private static DataNode<ProjectData> convert(@NotNull ProjectSystemId systemId, @NotNull ExternalProjectPojo rootProject, @NotNull Collection<ExternalProjectPojo> childProjects, @NotNull Map<String, Collection<ExternalTaskPojo>> availableTasks) {
    ProjectData projectData = new ProjectData(systemId, rootProject.getName(), rootProject.getPath(), rootProject.getPath());
    DataNode<ProjectData> projectDataNode = new DataNode<>(PROJECT, projectData, null);
    for (ExternalProjectPojo childProject : childProjects) {
        String moduleConfigPath = childProject.getPath();
        ModuleData moduleData = new ModuleData(childProject.getName(), systemId, ModuleTypeId.JAVA_MODULE, childProject.getName(), moduleConfigPath, moduleConfigPath);
        final DataNode<ModuleData> moduleDataNode = projectDataNode.createChild(MODULE, moduleData);
        final Collection<ExternalTaskPojo> moduleTasks = availableTasks.get(moduleConfigPath);
        if (moduleTasks != null) {
            for (ExternalTaskPojo moduleTask : moduleTasks) {
                TaskData taskData = new TaskData(systemId, moduleTask.getName(), moduleConfigPath, moduleTask.getDescription());
                moduleDataNode.createChild(TASK, taskData);
            }
        }
    }
    return projectDataNode;
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) TaskData(com.intellij.openapi.externalSystem.model.task.TaskData)

Example 4 with ExternalTaskPojo

use of com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo in project intellij-community by JetBrains.

the class ExternalSystemTasksTreeModel method ensureTasks.

public void ensureTasks(@NotNull String externalProjectConfigPath, @NotNull Collection<ExternalTaskPojo> tasks) {
    if (tasks.isEmpty()) {
        return;
    }
    ExternalSystemNode<ExternalProjectPojo> moduleNode = findProjectNode(externalProjectConfigPath);
    if (moduleNode == null) {
        //      ));
        return;
    }
    Set<ExternalTaskExecutionInfo> toAdd = ContainerUtilRt.newHashSet();
    for (ExternalTaskPojo task : tasks) {
        toAdd.add(buildTaskInfo(task));
    }
    for (int i = 0; i < moduleNode.getChildCount(); i++) {
        ExternalSystemNode<?> childNode = moduleNode.getChildAt(i);
        Object element = childNode.getDescriptor().getElement();
        if (element instanceof ExternalTaskExecutionInfo) {
            if (!toAdd.remove(element)) {
                removeNodeFromParent(childNode);
                //noinspection AssignmentToForLoopParameter
                i--;
            }
        }
    }
    if (!toAdd.isEmpty()) {
        for (ExternalTaskExecutionInfo taskInfo : toAdd) {
            insertNodeInto(new ExternalSystemNode<>(descriptor(taskInfo, taskInfo.getDescription(), myUiAware.getTaskIcon())), moduleNode);
        }
    }
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)

Example 5 with ExternalTaskPojo

use of com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo in project moe-ide-integration by multi-os-engine.

the class MOESdkPlugin method isValidMoeModule.

public static boolean isValidMoeModule(Module module, String taskName) {
    if (module == null) {
        return false;
    }
    final String moduleName = module.getName();
    if (module.isDisposed()) {
        LOG.info("Invalid MOE module, already disposed (" + moduleName + ")");
        return false;
    }
    if (ModuleUtils.isMavenModule(module)) {
        return ModuleUtils.isMOEMavenModule(module);
    }
    final Project project = module.getProject();
    final String path = ModuleUtils.getModulePath(module);
    final GradleLocalSettings localSettings = GradleLocalSettings.getInstance(project);
    // Get available projects
    Collection<ExternalProjectPojo> availableProjects = null;
    for (Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : localSettings.getAvailableProjects().entrySet()) {
        if (entry.getKey().getPath().equals(project.getBasePath())) {
            availableProjects = entry.getValue();
            break;
        }
    }
    if (availableProjects == null) {
        LOG.info("Not found available projects: " + moduleName);
        return false;
    }
    // Match IDEA module to Gradle project/subproject
    for (ExternalProjectPojo availableProject : availableProjects) {
        if (availableProject.getPath().equals(path)) {
            if (!availableProject.getName().equals(moduleName) && !availableProject.getName().endsWith(":" + moduleName)) {
                LOG.info("Could not associate IDEA module with Gradle project: " + moduleName);
                return false;
            }
            break;
        }
    }
    // Check for moeLaunch task
    Map<String, Collection<ExternalTaskPojo>> tasks = localSettings.getAvailableTasks();
    Collection<ExternalTaskPojo> taskPojos = tasks.get(path);
    if (taskPojos == null) {
        LOG.info("Not found gradle task pojos: " + moduleName);
        return false;
    }
    for (ExternalTaskPojo taskPojo : taskPojos) {
        if (taskName.equals(taskPojo.getName())) {
            return true;
        }
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) GradleLocalSettings(org.jetbrains.plugins.gradle.settings.GradleLocalSettings) Collection(java.util.Collection) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)

Aggregations

ExternalTaskPojo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo)8 ExternalProjectPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)4 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)2 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)2 ExternalTaskExecutionInfo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo)2 ProgramRunner (com.intellij.execution.runners.ProgramRunner)1 ExternalProjectBuildClasspathPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectBuildClasspathPojo)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)1 ExternalSystemExecutionSettings (com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings)1 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)1 ExternalSystemFacadeManager (com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager)1 RemoteExternalSystemFacade (com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade)1 RemoteExternalSystemTaskManager (com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager)1 Project (com.intellij.openapi.project.Project)1 Key (com.intellij.openapi.util.Key)1 KeyFMap (com.intellij.util.keyFMap.KeyFMap)1 Collection (java.util.Collection)1 GradleLocalSettings (org.jetbrains.plugins.gradle.settings.GradleLocalSettings)1