use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method brokenTask.
private Task brokenTask(String name, final RuntimeException failure, 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(failure));
allowing(state).rethrowFailure();
will(throwException(failure));
}
});
return task;
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class JacocoPluginExtension method applyTo.
/**
* Applies Jacoco to the given task.
* Configuration options will be provided on a task extension named 'jacoco'.
* Jacoco will be run as an agent during the execution of the task.
*
* @param task the task to apply Jacoco to.
* @see JacocoPluginExtension#TASK_EXTENSION_NAME
*/
public <T extends Task & JavaForkOptions> void applyTo(final T task) {
final String taskName = task.getName();
logger.debug("Applying Jacoco to " + taskName);
final JacocoTaskExtension extension = task.getExtensions().create(TASK_EXTENSION_NAME, JacocoTaskExtension.class, agent, task);
((IConventionAware) extension).getConventionMapping().map("destinationFile", new Callable<File>() {
@Override
public File call() {
return project.file(String.valueOf(project.getBuildDir()) + "/jacoco/" + taskName + ".exec");
}
});
task.getInputs().property("jacoco.enabled", new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return extension.isEnabled();
}
});
task.getInputs().property("jacoco.jvmArgs", new Callable<String>() {
@Override
public String call() throws Exception {
return extension.getAsJvmArg();
}
});
TaskInternal taskInternal = (TaskInternal) task;
taskInternal.getOutputs().doNotCacheIf("Jacoco configured to not produce its output as a file", new Spec<Task>() {
@Override
public boolean isSatisfiedBy(Task element) {
// Do not cache Test task if Jacoco doesn't produce its output as files
return extension.isEnabled() && extension.getOutput() != JacocoTaskExtension.Output.FILE;
}
});
taskInternal.getOutputs().file(new Callable<File>() {
@Override
public File call() throws Exception {
return extension.getDestinationFile();
}
}).optional().withPropertyName("jacoco.destinationFile");
taskInternal.getOutputs().dir(new Callable<File>() {
@Override
public File call() throws Exception {
return extension.getClassDumpDir();
}
}).optional().withPropertyName("jacoco.classDumpDir");
taskInternal.prependParallelSafeAction(new Action<Task>() {
@Override
public void execute(Task input) {
if (extension.isEnabled()) {
task.jvmArgs(extension.getAsJvmArg());
}
}
});
// Do not cache the Test task if we are appending to the Jacoco output
taskInternal.getOutputs().doNotCacheIf("Jacoco agent configured with `append = true`", new Spec<Task>() {
@Override
public boolean isSatisfiedBy(Task element) {
return extension.isAppend();
}
});
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class DefaultTaskExecutionPlan method recordTaskCompleted.
private void recordTaskCompleted(TaskInfo taskInfo) {
TaskInternal task = taskInfo.getTask();
String projectPath = task.getProject().getPath();
if (!isParallelizable(task)) {
projectsWithRunningNonParallelizableTasks.remove(projectPath);
}
projectsWithRunningTasks.remove(projectPath);
canonicalizedOutputCache.remove(task);
isParallelSafeCache.remove(task);
runningTasks.remove(task);
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class DefaultTaskExecutionPlan method recordTaskStarted.
private void recordTaskStarted(TaskInfo taskInfo) {
TaskInternal task = taskInfo.getTask();
String projectPath = task.getProject().getPath();
if (!isParallelizable(task)) {
projectsWithRunningNonParallelizableTasks.add(projectPath);
}
projectsWithRunningTasks.add(projectPath);
runningTasks.add(task);
}
use of org.gradle.api.internal.TaskInternal in project gradle by gradle.
the class ClientForwardingTaskOperationListener method started.
@Override
public void started(BuildOperationInternal buildOperation, OperationStartEvent startEvent) {
if (skipEvents.contains(buildOperation.getParentId())) {
skipEvents.add(buildOperation.getId());
return;
}
if (buildOperation.getOperationDescriptor() instanceof TaskOperationDescriptor) {
if (clientSubscriptions.isSendTaskProgressEvents()) {
TaskInternal task = ((TaskOperationDescriptor) buildOperation.getOperationDescriptor()).getTask();
eventConsumer.dispatch(new DefaultTaskStartedProgressEvent(startEvent.getStartTime(), toTaskDescriptor(buildOperation, task)));
} else {
// Discard this operation and all children
skipEvents.add(buildOperation.getId());
}
} else {
delegate.started(buildOperation, startEvent);
}
}
Aggregations