org.gradle.tooling.model.GradleTask Java Examples

The following examples show how to use org.gradle.tooling.model.GradleTask. 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: BuildInvocationsConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private List<ConsumerProvidedTask> convertTasks(Iterable<? extends GradleTask> tasks) {
    List<ConsumerProvidedTask> result = Lists.newArrayList();
    for (GradleTask task : tasks) {
        result.add(new ConsumerProvidedTask()
                .setName(task.getName())
                .setPath(task.getPath())
                .setDescription(task.getDescription()));
    }
    return result;
}
 
Example #5
Source File: BuildInvocationsConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private List<DefaultGradleTask> convertTasks(Iterator<? extends GradleTask> tasks) {
    return Lists.newArrayList(Iterators.transform(
            tasks,
            new Function<GradleTask, DefaultGradleTask>() {
                public DefaultGradleTask apply(GradleTask task) {
                    return new DefaultGradleTask()
                            .setName(task.getName())
                            .setPath(task.getPath())
                            .setDescription(task.getDescription());
                }
            }
    ));
}
 
Example #6
Source File: BuildInvocationsConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private List<DefaultGradleTask> convertTasks(Iterator<? extends GradleTask> tasks) {
    return Lists.newArrayList(Iterators.transform(
            tasks,
            new Function<GradleTask, DefaultGradleTask>() {
                public DefaultGradleTask apply(GradleTask task) {
                    return new DefaultGradleTask()
                            .setName(task.getName())
                            .setPath(task.getPath())
                            .setDescription(task.getDescription());
                }
            }
    ));
}
 
Example #7
Source File: GradleProjectSettingsConfigurator.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private boolean hasSpringFormatPlugin(EclipseProject eclipseProject) {
	if (eclipseProject != null) {
		for (GradleTask task : eclipseProject.getGradleProject().getTasks()) {
			if (isSpringFormatPlugin(task)) {
				return true;
			}
		}
	}
	return false;
}
 
Example #8
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 #9
Source File: BuildInvocationsConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private List<ConsumerProvidedTask> convertTasks(Iterable<? extends GradleTask> tasks) {
    List<ConsumerProvidedTask> result = Lists.newArrayList();
    for (GradleTask task : tasks) {
        result.add(new ConsumerProvidedTask()
                .setName(task.getName())
                .setPath(task.getPath())
                .setDescription(task.getDescription()));
    }
    return result;
}
 
Example #10
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());
    }
}
 
Example #11
Source File: TaskPropertyHandlerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(SourceObjectMapping mapping) {
    if (GradleTask.class.isAssignableFrom(mapping.getTargetType()) && !versionDetails.supportsTaskDisplayName()) {
        mapping.mixIn(GradleTaskDisplayNameMixInHandler.class);
    }
}
 
Example #12
Source File: GradleTaskDisplayNameMixInHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GradleTaskDisplayNameMixInHandler(GradleTask task) {
    this.task = task;
}
 
Example #13
Source File: GradleTaskDisplayNameMixInHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GradleTaskDisplayNameMixInHandler(GradleTask task) {
    this.task = task;
}
 
Example #14
Source File: TaskPropertyHandlerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(SourceObjectMapping mapping) {
    if (GradleTask.class.isAssignableFrom(mapping.getTargetType()) && !versionDetails.supportsTaskDisplayName()) {
        mapping.mixIn(GradleTaskDisplayNameMixInHandler.class);
    }
}
 
Example #15
Source File: GradleTaskDisplayNameMixInHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GradleTaskDisplayNameMixInHandler(GradleTask task) {
    this.task = task;
}
 
Example #16
Source File: GradleConnector.java    From MSPaintIDE with MIT License 4 votes vote down vote up
public List<String> getGradleTaskNames() {
    List<String> taskNames = new ArrayList<>();
    List<GradleTask> tasks = getGradleTasks();
    return tasks.stream().map(Task::getName).collect(Collectors.toList());
}
 
Example #17
Source File: GradleProjectSettingsConfigurator.java    From spring-javaformat with Apache License 2.0 4 votes vote down vote up
private boolean isSpringFormatPlugin(GradleTask task) {
	return TASK_NAME.equals(task.getName());
}
 
Example #18
Source File: TaskPropertyHandlerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(SourceObjectMapping mapping) {
    if (GradleTask.class.isAssignableFrom(mapping.getTargetType()) && !versionDetails.supportsTaskDisplayName()) {
        mapping.mixIn(GradleTaskDisplayNameMixInHandler.class);
    }
}
 
Example #19
Source File: GradleTaskDisplayNameMixInHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GradleTaskDisplayNameMixInHandler(GradleTask task) {
    this.task = task;
}
 
Example #20
Source File: TaskPropertyHandlerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(SourceObjectMapping mapping) {
    if (GradleTask.class.isAssignableFrom(mapping.getTargetType()) && !versionDetails.supportsTaskDisplayName()) {
        mapping.mixIn(GradleTaskDisplayNameMixInHandler.class);
    }
}