Java Code Examples for org.gradle.tooling.model.GradleProject#getTasks()

The following examples show how to use org.gradle.tooling.model.GradleProject#getTasks() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuildInvocationsConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private List<BasicGradleTaskSelector> buildRecursively(GradleProject project) {
    Multimap<String, String> aggregatedTasks = ArrayListMultimap.create();
    for (GradleProject childProject : project.getChildren()) {
        List<BasicGradleTaskSelector> childSelectors = buildRecursively(childProject);
        for (BasicGradleTaskSelector childSelector : childSelectors) {
            aggregatedTasks.putAll(childSelector.getName(), childSelector.getTaskNames());
        }
    }
    for (GradleTask task : project.getTasks()) {
        aggregatedTasks.put(task.getName(), task.getPath());
    }
    List<BasicGradleTaskSelector> selectors = Lists.newArrayList();
    for (String selectorName : aggregatedTasks.keySet()) {
        SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator());
        selectorTasks.addAll(aggregatedTasks.get(selectorName));
        selectors.add(new BasicGradleTaskSelector().
                setName(selectorName).
                setTaskNames(selectorTasks).
                setDescription(project.getParent() != null
                        ? String.format("%s:%s task selector", project.getPath(), selectorName)
                        : String.format("%s task selector", selectorName)).
                setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName())));
    }
    return selectors;
}
 
Example 2
Source File: BuildInvocationsConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private List<BasicGradleTaskSelector> buildRecursively(GradleProject project) {
    Multimap<String, String> aggregatedTasks = ArrayListMultimap.create();
    for (GradleProject childProject : project.getChildren()) {
        List<BasicGradleTaskSelector> childSelectors = buildRecursively(childProject);
        for (BasicGradleTaskSelector childSelector : childSelectors) {
            aggregatedTasks.putAll(childSelector.getName(), childSelector.getTaskNames());
        }
    }
    for (GradleTask task : project.getTasks()) {
        aggregatedTasks.put(task.getName(), task.getPath());
    }
    List<BasicGradleTaskSelector> selectors = Lists.newArrayList();
    for (String selectorName : aggregatedTasks.keySet()) {
        SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator());
        selectorTasks.addAll(aggregatedTasks.get(selectorName));
        selectors.add(new BasicGradleTaskSelector().
                setName(selectorName).
                setTaskNames(selectorTasks).
                setDescription(project.getParent() != null
                        ? String.format("%s:%s task selector", project.getPath(), selectorName)
                        : String.format("%s task selector", selectorName)).
                setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName())));
    }
    return selectors;
}
 
Example 3
Source File: BuildInvocationsConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void collectTasks(GradleProject project, Multimap<String, String> aggregatedTasks) {
    for (GradleProject childProject : project.getChildren()) {
        collectTasks(childProject, aggregatedTasks);
    }
    for (GradleTask task : project.getTasks()) {
        aggregatedTasks.put(task.getName(), task.getPath());
    }
}
 
Example 4
Source File: GradleConnector.java    From MSPaintIDE with MIT License 5 votes vote down vote up
public List<GradleTask> getGradleTasks() {
    List<GradleTask> tasks;
    try (ProjectConnection connection = connector.connect()) {
        GradleProject project = connection.getModel(GradleProject.class);
        tasks = new ArrayList<>(project.getTasks());
    }
    return tasks;
}
 
Example 5
Source File: BuildInvocationsConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void collectTasks(GradleProject project, Multimap<String, String> aggregatedTasks) {
    for (GradleProject childProject : project.getChildren()) {
        collectTasks(childProject, aggregatedTasks);
    }
    for (GradleTask task : project.getTasks()) {
        aggregatedTasks.put(task.getName(), task.getPath());
    }
}