Search in sources :

Example 1 with ResolvedTaskPath

use of org.gradle.execution.taskpath.ResolvedTaskPath in project gradle by gradle.

the class TaskSelector method getFilter.

public Spec<Task> getFilter(String path) {
    final ResolvedTaskPath taskPath = taskPathResolver.resolvePath(path, gradle.getDefaultProject());
    if (!taskPath.isQualified()) {
        ProjectInternal targetProject = taskPath.getProject();
        configurer.configure(targetProject);
        if (taskNameResolver.tryFindUnqualifiedTaskCheaply(taskPath.getTaskName(), taskPath.getProject())) {
            // An exact match in the target project - can just filter tasks by path to avoid configuring sub-projects at this point
            return new TaskPathSpec(targetProject, taskPath.getTaskName());
        }
    }
    final Set<Task> selectedTasks = getSelection(path, gradle.getDefaultProject()).getTasks();
    return new Spec<Task>() {

        public boolean isSatisfiedBy(Task element) {
            return !selectedTasks.contains(element);
        }
    };
}
Also used : ResolvedTaskPath(org.gradle.execution.taskpath.ResolvedTaskPath) Task(org.gradle.api.Task) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Spec(org.gradle.api.specs.Spec)

Example 2 with ResolvedTaskPath

use of org.gradle.execution.taskpath.ResolvedTaskPath in project gradle by gradle.

the class TaskSelector method getSelection.

private TaskSelection getSelection(String path, ProjectInternal project) {
    ResolvedTaskPath taskPath = taskPathResolver.resolvePath(path, project);
    ProjectInternal targetProject = taskPath.getProject();
    if (taskPath.isQualified()) {
        configurer.configure(targetProject);
    } else {
        configurer.configureHierarchy(targetProject);
    }
    TaskSelectionResult tasks = taskNameResolver.selectWithName(taskPath.getTaskName(), taskPath.getProject(), !taskPath.isQualified());
    if (tasks != null) {
        // An exact match
        return new TaskSelection(taskPath.getProject().getPath(), path, tasks);
    }
    Map<String, TaskSelectionResult> tasksByName = taskNameResolver.selectAll(taskPath.getProject(), !taskPath.isQualified());
    NameMatcher matcher = new NameMatcher();
    String actualName = matcher.find(taskPath.getTaskName(), tasksByName.keySet());
    if (actualName != null) {
        return new TaskSelection(taskPath.getProject().getPath(), taskPath.getPrefix() + actualName, tasksByName.get(actualName));
    }
    throw new TaskSelectionException(matcher.formatErrorMessage("task", taskPath.getProject()));
}
Also used : ResolvedTaskPath(org.gradle.execution.taskpath.ResolvedTaskPath) NameMatcher(org.gradle.util.NameMatcher) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 3 with ResolvedTaskPath

use of org.gradle.execution.taskpath.ResolvedTaskPath in project gradle by gradle.

the class DefaultTaskSelector method getSelection.

private TaskSelection getSelection(String path, ProjectInternal project) {
    ResolvedTaskPath taskPath = taskPathResolver.resolvePath(path, project);
    ProjectInternal targetProject = taskPath.getProject();
    if (taskPath.isQualified()) {
        configurer.configure(targetProject);
    } else {
        configurer.configureHierarchy(targetProject);
    }
    TaskSelectionResult tasks = taskNameResolver.selectWithName(taskPath.getTaskName(), taskPath.getProject(), !taskPath.isQualified());
    if (tasks != null) {
        // An exact match
        return new TaskSelection(taskPath.getProject().getPath(), path, tasks);
    }
    Map<String, TaskSelectionResult> tasksByName = taskNameResolver.selectAll(taskPath.getProject(), !taskPath.isQualified());
    NameMatcher matcher = new NameMatcher();
    String actualName = matcher.find(taskPath.getTaskName(), tasksByName.keySet());
    if (actualName != null) {
        return new TaskSelection(taskPath.getProject().getPath(), taskPath.getPrefix() + actualName, tasksByName.get(actualName));
    }
    throw new TaskSelectionException(matcher.formatErrorMessage("task", taskPath.getProject()));
}
Also used : ResolvedTaskPath(org.gradle.execution.taskpath.ResolvedTaskPath) NameMatcher(org.gradle.util.internal.NameMatcher) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 4 with ResolvedTaskPath

use of org.gradle.execution.taskpath.ResolvedTaskPath in project gradle by gradle.

the class DefaultTaskSelector method getFilter.

public Spec<Task> getFilter(String path) {
    final ResolvedTaskPath taskPath = taskPathResolver.resolvePath(path, gradle.getDefaultProject());
    if (!taskPath.isQualified()) {
        ProjectInternal targetProject = taskPath.getProject();
        configurer.configure(targetProject);
        if (taskNameResolver.tryFindUnqualifiedTaskCheaply(taskPath.getTaskName(), taskPath.getProject())) {
            // An exact match in the target project - can just filter tasks by path to avoid configuring sub-projects at this point
            return new TaskPathSpec(targetProject, taskPath.getTaskName());
        }
    }
    final Set<Task> selectedTasks = getSelection(path, gradle.getDefaultProject()).getTasks();
    return new Spec<Task>() {

        @Override
        public boolean isSatisfiedBy(Task element) {
            return !selectedTasks.contains(element);
        }
    };
}
Also used : ResolvedTaskPath(org.gradle.execution.taskpath.ResolvedTaskPath) Task(org.gradle.api.Task) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Spec(org.gradle.api.specs.Spec)

Aggregations

ProjectInternal (org.gradle.api.internal.project.ProjectInternal)4 ResolvedTaskPath (org.gradle.execution.taskpath.ResolvedTaskPath)4 Task (org.gradle.api.Task)2 Spec (org.gradle.api.specs.Spec)2 NameMatcher (org.gradle.util.NameMatcher)1 NameMatcher (org.gradle.util.internal.NameMatcher)1