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);
}
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);
}
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;
}
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);
}
}
}
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;
}
Aggregations