@Override public void executeTasks( @NotNull final ExternalSystemTaskId id, @NotNull final List<String> taskNames, @NotNull String projectPath, @Nullable final GradleExecutionSettings settings) throws ExternalSystemException { Function<ProjectConnection, Void> f = new Function<ProjectConnection, Void>() { @Override public Void fun(ProjectConnection connection) { BuildLauncher launcher = myHelper.getBuildLauncher(id, connection, settings); launcher.forTasks(ArrayUtil.toStringArray(taskNames)); launcher.run(); return null; } }; myHelper.execute(projectPath, settings, f); }
@Override public Collection<ExternalSystemTaskDescriptor> listTasks( @NotNull final ExternalSystemTaskId id, @NotNull String projectPath, @Nullable final GradleExecutionSettings settings) throws ExternalSystemException { Function<ProjectConnection, Collection<ExternalSystemTaskDescriptor>> f = new Function<ProjectConnection, Collection<ExternalSystemTaskDescriptor>>() { @Nullable @Override public Collection<ExternalSystemTaskDescriptor> fun(ProjectConnection connection) { ModelBuilder<? extends IdeaProject> modelBuilder = myHelper.getModelBuilder(id, settings, connection, false); IdeaProject project = modelBuilder.get(); DomainObjectSet<? extends IdeaModule> modules = project.getModules(); if (modules == null) { return Collections.emptyList(); } Set<ExternalSystemTaskDescriptor> result = new HashSet<ExternalSystemTaskDescriptor>(); for (IdeaModule module : modules) { for (GradleTask task : module.getGradleProject().getTasks()) { String name = task.getName(); if (name == null || name.trim().isEmpty()) { continue; } String s = name.toLowerCase(); if (s.contains("idea") || s.contains("eclipse")) { continue; } result.add(new ExternalSystemTaskDescriptor(name, task.getDescription())); } } return result; } }; return myHelper.execute(projectPath, settings, f); }