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