use of org.gradle.api.internal.changedetection.state.FileSnapshot in project gradle by gradle.
the class TarTaskOutputPacker method unpack.
private UnpackResult unpack(SortedSet<ResolvedTaskOutputFilePropertySpec> propertySpecs, TarArchiveInputStream tarInput, TaskOutputOriginReader readOriginAction) throws IOException {
Map<String, ResolvedTaskOutputFilePropertySpec> propertySpecsMap = Maps.uniqueIndex(propertySpecs, new Function<TaskFilePropertySpec, String>() {
@Override
public String apply(TaskFilePropertySpec propertySpec) {
return propertySpec.getPropertyName();
}
});
TarArchiveEntry tarEntry;
OriginTaskExecutionMetadata originMetadata = null;
ImmutableListMultimap.Builder<String, FileSnapshot> propertyFileSnapshots = ImmutableListMultimap.builder();
long entries = 0;
while ((tarEntry = tarInput.getNextTarEntry()) != null) {
++entries;
String path = tarEntry.getName();
if (path.equals(METADATA_PATH)) {
// handle origin metadata
originMetadata = readOriginAction.execute(new CloseShieldInputStream(tarInput));
} else {
// handle output property
Matcher matcher = PROPERTY_PATH.matcher(path);
if (!matcher.matches()) {
throw new IllegalStateException("Cached result format error, invalid contents: " + path);
}
String propertyName = unescape(matcher.group(2));
ResolvedTaskOutputFilePropertySpec propertySpec = propertySpecsMap.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, tarEntry, childPath, outputMissing, propertyFileSnapshots);
}
}
if (originMetadata == null) {
throw new IllegalStateException("Cached result format error, no origin metadata was found.");
}
return new UnpackResult(originMetadata, entries, propertyFileSnapshots.build());
}
use of org.gradle.api.internal.changedetection.state.FileSnapshot in project gradle by gradle.
the class DefaultSourceIncludesResolver method searchForDependency.
private void searchForDependency(List<File> searchPath, String include, BuildableResult dependencies) {
for (File searchDir : searchPath) {
Map<String, IncludeFileImpl> searchedIncludes = includeRoots.get(searchDir);
if (searchedIncludes == null) {
searchedIncludes = new HashMap<String, IncludeFileImpl>();
includeRoots.put(searchDir, searchedIncludes);
}
if (searchedIncludes.containsKey(include)) {
IncludeFileImpl includeFile = searchedIncludes.get(include);
if (includeFile.snapshot.getType() == FileType.RegularFile) {
dependencies.resolved(includeFile);
return;
}
continue;
}
File candidate = new File(searchDir, include);
FileSnapshot fileSnapshot = fileSystemSnapshotter.snapshotSelf(candidate);
IncludeFileImpl includeFile = fileSnapshot.getType() == FileType.RegularFile ? new IncludeFileImpl(candidate, fileSnapshot) : new IncludeFileImpl(null, fileSnapshot);
searchedIncludes.put(include, includeFile);
if (fileSnapshot.getType() == FileType.RegularFile) {
dependencies.resolved(includeFile);
return;
}
}
}
Aggregations