use of org.gradle.api.internal.tasks.TaskFilePropertySpec in project gradle by gradle.
the class AbstractNamedFileSnapshotTaskStateChanges method buildSnapshots.
protected static ImmutableSortedMap<String, FileCollectionSnapshot> buildSnapshots(String taskName, FileCollectionSnapshotterRegistry snapshotterRegistry, String title, SortedSet<? extends TaskFilePropertySpec> fileProperties) {
ImmutableSortedMap.Builder<String, FileCollectionSnapshot> builder = ImmutableSortedMap.naturalOrder();
for (TaskFilePropertySpec propertySpec : fileProperties) {
FileCollectionSnapshot result;
try {
FileCollectionSnapshotter snapshotter = snapshotterRegistry.getSnapshotter(propertySpec.getSnapshotter());
result = snapshotter.snapshot(propertySpec.getPropertyFiles(), propertySpec.getCompareStrategy(), propertySpec.getSnapshotNormalizationStrategy());
} catch (UncheckedIOException e) {
throw new UncheckedIOException(String.format("Failed to capture snapshot of %s files for task '%s' property '%s' during up-to-date check.", title.toLowerCase(), taskName, propertySpec.getPropertyName()), e);
}
builder.put(propertySpec.getPropertyName(), result);
}
return builder.build();
}
use of org.gradle.api.internal.tasks.TaskFilePropertySpec in project gradle by gradle.
the class TarTaskOutputPacker method unpack.
private void unpack(TaskOutputsInternal taskOutputs, TarInputStream tarInput, TaskOutputOriginReader readOriginAction) throws IOException {
Map<String, TaskOutputFilePropertySpec> propertySpecs = Maps.uniqueIndex(taskOutputs.getFileProperties(), new Function<TaskFilePropertySpec, String>() {
@Override
public String apply(TaskFilePropertySpec propertySpec) {
return propertySpec.getPropertyName();
}
});
boolean originSeen = false;
TarEntry entry;
while ((entry = tarInput.getNextEntry()) != null) {
String name = entry.getName();
if (name.equals(METADATA_PATH)) {
// handle origin metadata
originSeen = true;
readOriginAction.execute(new CloseShieldInputStream(tarInput));
} else {
// handle output property
Matcher matcher = PROPERTY_PATH.matcher(name);
if (!matcher.matches()) {
throw new IllegalStateException("Cached result format error, invalid contents: " + name);
}
String propertyName = matcher.group(2);
CacheableTaskOutputFilePropertySpec propertySpec = (CacheableTaskOutputFilePropertySpec) propertySpecs.get(propertyName);
if (propertySpec == null) {
throw new IllegalStateException(String.format("No output property '%s' registered", propertyName));
}
boolean outputMissing = matcher.group(1) != null;
String childPath = matcher.group(3);
unpackPropertyEntry(propertySpec, tarInput, entry, childPath, outputMissing);
}
}
if (!originSeen) {
throw new IllegalStateException("Cached result format error, no origin metadata was found.");
}
}
Aggregations