use of org.gradle.api.tasks.TaskOutputs 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.tasks.TaskOutputs 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.tasks.TaskOutputs in project gradle by gradle.
the class BuildDependenciesOnlyFileCollectionResolveContext method add.
@Override
public FileCollectionResolveContext add(Object element) {
// TODO - need to sync with DefaultFileCollectionResolveContext
if (element instanceof Buildable) {
taskContext.add(element);
} else if (element instanceof Task) {
taskContext.add(element);
} else if (element instanceof TaskOutputs) {
TaskOutputs outputs = (TaskOutputs) element;
taskContext.add(outputs.getFiles());
} else if (element instanceof RegularFileProperty || element instanceof DirectoryProperty) {
taskContext.add(element);
} else if (element instanceof Closure) {
Closure closure = (Closure) element;
Object closureResult = closure.call();
if (closureResult != null) {
add(closureResult);
}
} else if (element instanceof Callable) {
Callable callable = (Callable) element;
Object callableResult = uncheckedCall(callable);
if (callableResult != null) {
add(callableResult);
}
} else if (element instanceof Iterable && !(element instanceof Path)) {
// Ignore Path
Iterable<?> iterable = (Iterable) element;
for (Object value : iterable) {
add(value);
}
} else if (element instanceof Object[]) {
Object[] array = (Object[]) element;
for (Object value : array) {
add(value);
}
}
// Everything else assume has no dependencies
return this;
}
use of org.gradle.api.tasks.TaskOutputs 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.tasks.TaskOutputs in project gradle by gradle.
the class DefaultFileCollectionResolveContext method doResolve.
private <T> List<T> doResolve(Converter<? extends T> converter) {
List<T> result = new ArrayList<T>();
while (!queue.isEmpty()) {
Object element = queue.remove(0);
// TODO - need to sync with BuildDependenciesOnlyFileCollectionResolveContext
if (element instanceof DefaultFileCollectionResolveContext) {
DefaultFileCollectionResolveContext nestedContext = (DefaultFileCollectionResolveContext) element;
converter.convertInto(nestedContext, result, fileResolver);
} else if (element instanceof FileCollectionContainer) {
FileCollectionContainer fileCollection = (FileCollectionContainer) element;
resolveNested(fileCollection, result, converter);
} else if (element instanceof FileCollection || element instanceof MinimalFileCollection) {
converter.convertInto(element, result, fileResolver);
} else if (element instanceof Task) {
Task task = (Task) element;
queue.add(0, task.getOutputs().getFiles());
} else if (element instanceof TaskOutputs) {
TaskOutputs outputs = (TaskOutputs) element;
queue.add(0, outputs.getFiles());
} else if (element instanceof Callable) {
Callable callable = (Callable) element;
Object callableResult = uncheckedCall(callable);
if (callableResult != null) {
queue.add(0, callableResult);
}
} else if (element instanceof Provider) {
Provider provider = (Provider) element;
Object providerResult = provider.get();
queue.add(0, providerResult);
} else if (element instanceof Path) {
queue.add(0, ((Path) element).toFile());
} else if (element instanceof Iterable) {
Iterable<?> iterable = (Iterable) element;
GUtil.addToCollection(queue.subList(0, 0), iterable);
} else if (element instanceof Object[]) {
Object[] array = (Object[]) element;
GUtil.addToCollection(queue.subList(0, 0), Arrays.asList(array));
} else {
converter.convertInto(element, result, fileResolver);
}
}
return result;
}
Aggregations