use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class DependencyAutoWireTaskFactoryTest method addsDependencyOnInputFiles.
@Test
public void addsDependencyOnInputFiles() {
final TaskInternal task = context.mock(TaskInternal.class);
final TaskInputsInternal taskInputs = context.mock(TaskInputsInternal.class);
final FileCollection inputFiles = context.mock(FileCollection.class);
context.checking(new Expectations() {
{
one(delegate).createTask(map());
will(returnValue(task));
allowing(task).getInputs();
will(returnValue(taskInputs));
allowing(taskInputs).getFiles();
will(returnValue(inputFiles));
one(task).dependsOn(inputFiles);
}
});
assertThat(factory.createTask(map()), sameInstance(task));
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method createTask.
private TaskInternal createTask(final String name) {
TaskInternal task = context.mock(TaskInternal.class);
TaskStateInternal state = context.mock(TaskStateInternal.class);
final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
setExpectations(name, task, state, outputs);
return task;
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method task.
private Task task(final String name, final Task... dependsOn) {
final TaskInternal task = context.mock(TaskInternal.class);
final TaskStateInternal state = context.mock(TaskStateInternal.class);
final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
setExpectations(name, task, state, outputs);
dependsOn(task, dependsOn);
context.checking(new Expectations() {
{
atMost(1).of(executer).execute(with(sameInstance(task)), with(sameInstance(state)), with(notNullValue(TaskExecutionContext.class)));
will(new ExecuteTaskAction(task));
allowing(state).getFailure();
will(returnValue(null));
}
});
return task;
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class DefaultTaskExecutionPlan method canRunWithWithCurrentlyExecutedTasks.
private boolean canRunWithWithCurrentlyExecutedTasks(TaskInfo taskInfo) {
TaskInternal task = taskInfo.getTask();
String projectPath = task.getProject().getPath();
if (isParallelizable(task)) {
if (projectsWithRunningNonParallelizableTasks.contains(projectPath)) {
return false;
}
} else {
if (projectsWithRunningTasks.contains(projectPath)) {
return false;
}
}
Pair<TaskInternal, String> overlap = firstTaskWithOverlappingOutput(task);
if (overlap == null) {
return true;
} else {
LOGGER.info("Cannot execute task {} in parallel with task {} due to overlapping output: {}", task.getPath(), overlap.left.getPath(), overlap.right);
}
return false;
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class TaskFactory method createTask.
public TaskInternal createTask(Map<String, ?> args) {
Map<String, Object> actualArgs = new HashMap<String, Object>(args);
checkTaskArgsAndCreateDefaultValues(actualArgs);
String name = actualArgs.get(Task.TASK_NAME).toString();
if (!GUtil.isTrue(name)) {
throw new InvalidUserDataException("The task name must be provided.");
}
Class<? extends TaskInternal> type = (Class) actualArgs.get(Task.TASK_TYPE);
TaskInternal task = create(name, type);
Object dependsOnTasks = actualArgs.get(Task.TASK_DEPENDS_ON);
if (dependsOnTasks != null) {
task.dependsOn(dependsOnTasks);
}
Object description = actualArgs.get(Task.TASK_DESCRIPTION);
if (description != null) {
task.setDescription(description.toString());
}
Object group = actualArgs.get(Task.TASK_GROUP);
if (group != null) {
task.setGroup(group.toString());
}
Object action = actualArgs.get(Task.TASK_ACTION);
if (action instanceof Action) {
Action<? super Task> taskAction = (Action<? super Task>) action;
task.doFirst(taskAction);
} else if (action != null) {
Closure closure = (Closure) action;
task.doFirst(closure);
}
return task;
}
Aggregations