Search in sources :

Example 1 with TaskInternal

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));
}
Also used : Expectations(org.jmock.Expectations) TaskInternal(org.gradle.api.internal.TaskInternal) TaskInputsInternal(org.gradle.api.internal.TaskInputsInternal) FileCollection(org.gradle.api.file.FileCollection) Test(org.junit.Test)

Example 2 with TaskInternal

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;
}
Also used : TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) TaskInternal(org.gradle.api.internal.TaskInternal) DefaultTaskOutputs(org.gradle.api.internal.tasks.DefaultTaskOutputs) TaskOutputs(org.gradle.api.tasks.TaskOutputs)

Example 3 with TaskInternal

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;
}
Also used : Expectations(org.jmock.Expectations) TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) TaskInternal(org.gradle.api.internal.TaskInternal) DefaultTaskOutputs(org.gradle.api.internal.tasks.DefaultTaskOutputs) TaskOutputs(org.gradle.api.tasks.TaskOutputs) TaskExecutionContext(org.gradle.api.internal.tasks.TaskExecutionContext)

Example 4 with TaskInternal

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;
}
Also used : TaskInternal(org.gradle.api.internal.TaskInternal)

Example 5 with TaskInternal

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;
}
Also used : Action(org.gradle.api.Action) AbstractTask(org.gradle.api.internal.AbstractTask) Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask) Closure(groovy.lang.Closure) HashMap(java.util.HashMap) InvalidUserDataException(org.gradle.api.InvalidUserDataException) TaskInternal(org.gradle.api.internal.TaskInternal)

Aggregations

TaskInternal (org.gradle.api.internal.TaskInternal)28 Task (org.gradle.api.Task)7 TaskStateInternal (org.gradle.api.internal.tasks.TaskStateInternal)5 TaskOperationDescriptor (org.gradle.api.execution.internal.TaskOperationDescriptor)4 TaskExecutionContext (org.gradle.api.internal.tasks.TaskExecutionContext)4 Closure (groovy.lang.Closure)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 List (java.util.List)3 Action (org.gradle.api.Action)3 InvalidUserDataException (org.gradle.api.InvalidUserDataException)3 Set (java.util.Set)2 DefaultTask (org.gradle.api.DefaultTask)2 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 DefaultTaskOutputs (org.gradle.api.internal.tasks.DefaultTaskOutputs)2 TaskExecuter (org.gradle.api.internal.tasks.TaskExecuter)2 PropertyWalker (org.gradle.api.internal.tasks.properties.PropertyWalker)2 TaskOutputs (org.gradle.api.tasks.TaskOutputs)2 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)2