use of org.gradle.api.internal.tasks.NodeExecutionContext in project gradle by gradle.
the class TransformationStep method createInvocation.
public CacheableInvocation<TransformationSubject> createInvocation(TransformationSubject subjectToTransform, TransformUpstreamDependencies upstreamDependencies, @Nullable NodeExecutionContext context) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Transforming {} with {}", subjectToTransform.getDisplayName(), transformer.getDisplayName());
}
InputFingerprinter inputFingerprinter = context != null ? context.getService(InputFingerprinter.class) : globalInputFingerprinter;
Try<ArtifactTransformDependencies> resolvedDependencies = upstreamDependencies.computeArtifacts();
return resolvedDependencies.map(dependencies -> {
ImmutableList<File> inputArtifacts = subjectToTransform.getFiles();
if (inputArtifacts.isEmpty()) {
return CacheableInvocation.cached(Try.successful(subjectToTransform.createSubjectFromResult(ImmutableList.of())));
} else if (inputArtifacts.size() > 1) {
return CacheableInvocation.nonCached(() -> doTransform(subjectToTransform, inputFingerprinter, dependencies, inputArtifacts));
} else {
File inputArtifact = inputArtifacts.get(0);
return transformerInvocationFactory.createInvocation(transformer, inputArtifact, dependencies, subjectToTransform, inputFingerprinter).map(subjectToTransform::createSubjectFromResult);
}
}).getOrMapFailure(failure -> CacheableInvocation.cached(Try.failure(failure)));
}
Aggregations