Search in sources :

Example 1 with TaskSelection

use of org.gradle.execution.TaskSelection in project gradle by gradle.

the class CommandLineTaskParser method parseTasks.

public List<TaskSelection> parseTasks(TaskExecutionRequest taskExecutionRequest) {
    List<TaskSelection> out = Lists.newArrayList();
    List<String> remainingPaths = new LinkedList<String>(taskExecutionRequest.getArgs());
    while (!remainingPaths.isEmpty()) {
        String path = remainingPaths.remove(0);
        TaskSelection selection = taskSelector.getSelection(taskExecutionRequest.getProjectPath(), taskExecutionRequest.getRootDir(), path);
        Set<Task> tasks = selection.getTasks();
        remainingPaths = taskConfigurer.configureTasks(tasks, remainingPaths);
        out.add(selection);
    }
    return out;
}
Also used : TaskSelection(org.gradle.execution.TaskSelection) Task(org.gradle.api.Task) LinkedList(java.util.LinkedList)

Example 2 with TaskSelection

use of org.gradle.execution.TaskSelection in project gradle by gradle.

the class Help method printTaskHelp.

private void printTaskHelp(StyledTextOutput output) {
    TaskSelector selector = getTaskSelector();
    TaskSelection selection = selector.getSelection(taskPath);
    OptionReader optionReader = getOptionReader();
    TaskDetailPrinter taskDetailPrinter = new TaskDetailPrinter(taskPath, selection, optionReader);
    taskDetailPrinter.print(output);
}
Also used : TaskSelection(org.gradle.execution.TaskSelection) OptionReader(org.gradle.api.internal.tasks.options.OptionReader) TaskSelector(org.gradle.execution.TaskSelector)

Example 3 with TaskSelection

use of org.gradle.execution.TaskSelection in project gradle by gradle.

the class TestExecutionBuildConfigurationAction method queryTestTasks.

private Set<Test> queryTestTasks(String testTaskPath) {
    TaskSelection taskSelection;
    try {
        taskSelection = taskSelector.getSelection(testTaskPath);
    } catch (TaskSelectionException e) {
        throw new TestExecutionException(String.format("Requested test task with path '%s' cannot be found.", testTaskPath));
    }
    Set<Task> tasks = taskSelection.getTasks();
    if (tasks.isEmpty()) {
        throw new TestExecutionException(String.format("Requested test task with path '%s' cannot be found.", testTaskPath));
    }
    Set<Test> result = new LinkedHashSet<>();
    for (Task task : tasks) {
        if (!(task instanceof Test)) {
            throw new TestExecutionException(String.format("Task '%s' of type '%s' not supported for executing tests via TestLauncher API.", testTaskPath, task.getClass().getName()));
        }
        result.add((Test) task);
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TaskSelection(org.gradle.execution.TaskSelection) Task(org.gradle.api.Task) TestExecutionException(org.gradle.api.tasks.testing.TestExecutionException) Test(org.gradle.api.tasks.testing.Test) TaskSelectionException(org.gradle.execution.TaskSelectionException)

Aggregations

TaskSelection (org.gradle.execution.TaskSelection)3 Task (org.gradle.api.Task)2 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 OptionReader (org.gradle.api.internal.tasks.options.OptionReader)1 Test (org.gradle.api.tasks.testing.Test)1 TestExecutionException (org.gradle.api.tasks.testing.TestExecutionException)1 TaskSelectionException (org.gradle.execution.TaskSelectionException)1 TaskSelector (org.gradle.execution.TaskSelector)1