use of org.gradle.api.internal.tasks.TaskOutputFilePropertySpec 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