Search in sources :

Example 1 with LaunchableGradleTaskSelector

use of org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector in project gradle by gradle.

the class BuildInvocationsBuilder method findTasks.

private void findTasks(Project project, Map<String, LaunchableGradleTaskSelector> taskSelectors, Collection<String> visibleTasks) {
    for (Project child : project.getChildProjects().values()) {
        findTasks(child, taskSelectors, visibleTasks);
    }
    for (Task task : taskLister.listProjectTasks(project)) {
        // this way, for each task selector, its description will be the one from the selected task with the 'smallest' path
        if (!taskSelectors.containsKey(task.getName())) {
            LaunchableGradleTaskSelector taskSelector = new LaunchableGradleTaskSelector().setDescription(task.getDescription()).setPath(task.getPath());
            taskSelectors.put(task.getName(), taskSelector);
        } else {
            LaunchableGradleTaskSelector taskSelector = taskSelectors.get(task.getName());
            if (hasPathWithLowerOrdering(task, taskSelector)) {
                taskSelector.setDescription(task.getDescription()).setPath(task.getPath());
            }
        }
        // visible tasks are specified as those that have a non-empty group
        if (PublicTaskSpecification.INSTANCE.isSatisfiedBy(task)) {
            visibleTasks.add(task.getName());
        }
    }
}
Also used : Project(org.gradle.api.Project) ToolingModelBuilderSupport.buildFromTask(org.gradle.plugins.ide.internal.tooling.ToolingModelBuilderSupport.buildFromTask) LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) Task(org.gradle.api.Task) LaunchableGradleTaskSelector(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector)

Example 2 with LaunchableGradleTaskSelector

use of org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector in project gradle by gradle.

the class BuildInvocationsBuilder method buildAll.

@Override
@SuppressWarnings("StringEquality")
public DefaultBuildInvocations buildAll(String modelName, Project project) {
    if (!canBuild(modelName)) {
        throw new GradleException("Unknown model name " + modelName);
    }
    DefaultProjectIdentifier projectIdentifier = getProjectIdentifier(project);
    // construct task selectors
    List<LaunchableGradleTaskSelector> selectors = Lists.newArrayList();
    Map<String, LaunchableGradleTaskSelector> selectorsByName = Maps.newTreeMap(Ordering.natural());
    Set<String> visibleTasks = Sets.newLinkedHashSet();
    findTasks(project, selectorsByName, visibleTasks);
    for (String selectorName : selectorsByName.keySet()) {
        LaunchableGradleTaskSelector selector = selectorsByName.get(selectorName);
        selectors.add(selector.setName(selectorName).setTaskName(selectorName).setProjectIdentifier(projectIdentifier).setDisplayName(selectorName + " in " + project + " and subprojects.").setPublic(visibleTasks.contains(selectorName)));
    }
    // construct project tasks
    List<LaunchableGradleTask> projectTasks = tasks(project);
    // construct build invocations from task selectors and project tasks
    return new DefaultBuildInvocations().setSelectors(selectors).setTasks(projectTasks).setProjectIdentifier(projectIdentifier);
}
Also used : LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) DefaultBuildInvocations(org.gradle.plugins.ide.internal.tooling.model.DefaultBuildInvocations) GradleException(org.gradle.api.GradleException) LaunchableGradleTaskSelector(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Aggregations

LaunchableGradleTask (org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask)2 LaunchableGradleTaskSelector (org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector)2 GradleException (org.gradle.api.GradleException)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1 ToolingModelBuilderSupport.buildFromTask (org.gradle.plugins.ide.internal.tooling.ToolingModelBuilderSupport.buildFromTask)1 DefaultBuildInvocations (org.gradle.plugins.ide.internal.tooling.model.DefaultBuildInvocations)1 DefaultProjectIdentifier (org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)1