use of org.gradle.api.Task in project gradle by gradle.
the class TestUtility method createTask.
/**
* Creates a mock task with the specified properites.
*/
public static Task createTask(JUnit4Mockery context, final String name, final String description) {
final Task task = context.mock(Task.class, "[task]_" + name + '_' + uniqueNameCounter++);
context.checking(new Expectations() {
{
allowing(task).getName();
will(returnValue(name));
allowing(task).getDescription();
will(returnValue(description));
}
});
return task;
}
use of org.gradle.api.Task 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);
}
};
}
use of org.gradle.api.Task in project gradle by gradle.
the class DryRunBuildExecutionAction method execute.
public void execute(BuildExecutionContext context) {
GradleInternal gradle = context.getGradle();
if (gradle.getStartParameter().isDryRun()) {
for (Task task : gradle.getTaskGraph().getAllTasks()) {
task.setEnabled(false);
}
}
context.proceed();
}
use of org.gradle.api.Task in project gradle by gradle.
the class ExcludedTaskFilteringBuildConfigurationAction method configure.
public void configure(BuildExecutionContext context) {
GradleInternal gradle = context.getGradle();
Set<String> excludedTaskNames = gradle.getStartParameter().getExcludedTaskNames();
if (!excludedTaskNames.isEmpty()) {
final Set<Spec<Task>> filters = new HashSet<Spec<Task>>();
for (String taskName : excludedTaskNames) {
filters.add(taskSelector.getFilter(taskName));
}
gradle.getTaskGraph().useFilter(Specs.intersect(filters));
}
context.proceed();
}
use of org.gradle.api.Task in project gradle by gradle.
the class TaskDetailPrinter method printTaskAttribute.
private void printTaskAttribute(StyledTextOutput output, String attributeHeader, List<Task> tasks, Transformer<String, Task> transformer) {
int count = collect(tasks, new HashSet<String>(), transformer).size();
final LinePrefixingStyledTextOutput attributeOutput = createIndentedOutput(output, INDENT);
if (count == 1) {
// all tasks have the same value
attributeOutput.println(attributeHeader);
final Task task = tasks.iterator().next();
String value = transformer.transform(task);
attributeOutput.println(value == null ? "-" : value);
} else {
attributeOutput.println(attributeHeader + "s");
for (Task task : tasks) {
attributeOutput.withStyle(UserInput).text("(" + task.getPath() + ") ");
String value = transformer.transform(task);
attributeOutput.println(value == null ? "-" : value);
}
}
}
Aggregations