use of org.gradle.api.internal.changedetection.state.FileContentSnapshot in project gradle by gradle.
the class TarTaskOutputPacker method pack.
private long pack(Collection<ResolvedTaskOutputFilePropertySpec> propertySpecs, Map<String, Map<String, FileContentSnapshot>> outputSnapshots, TarArchiveOutputStream tarOutput) {
long entries = 0;
for (ResolvedTaskOutputFilePropertySpec propertySpec : propertySpecs) {
String propertyName = propertySpec.getPropertyName();
Map<String, FileContentSnapshot> outputs = outputSnapshots.get(propertyName);
try {
entries += packProperty(propertySpec, outputs, tarOutput);
} catch (Exception ex) {
throw new GradleException(String.format("Could not pack property '%s': %s", propertyName, ex.getMessage()), ex);
}
}
return entries;
}
use of org.gradle.api.internal.changedetection.state.FileContentSnapshot in project gradle by gradle.
the class TarTaskOutputPacker method storeDirectoryProperty.
private long storeDirectoryProperty(String propertyPath, File directory, Map<String, FileContentSnapshot> outputSnapshots, final TarArchiveOutputStream tarOutput) throws IOException {
if (!directory.isDirectory()) {
throw new IllegalArgumentException(String.format("Expected '%s' to be a directory", directory));
}
long entries = 0;
final String propertyRoot = propertyPath + "/";
createTarEntry(propertyRoot, 0, UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM, tarOutput);
tarOutput.closeArchiveEntry();
entries++;
String rootAbsolutePath = directory.getAbsolutePath();
Path rootPath = directory.toPath();
for (Map.Entry<String, FileContentSnapshot> entry : outputSnapshots.entrySet()) {
String absolutePath = entry.getKey();
// We've already created the directory for the property
if (absolutePath.equals(rootAbsolutePath)) {
continue;
}
File file = new File(absolutePath);
String relativePath = rootPath.relativize(file.toPath()).toString();
String targetPath = propertyRoot + relativePath;
int mode = fileSystem.getUnixMode(file);
switch(entry.getValue().getType()) {
case RegularFile:
storeFileEntry(file, targetPath, file.length(), mode, tarOutput);
break;
case Directory:
storeDirectoryEntry(targetPath, mode, tarOutput);
break;
case Missing:
throw new IllegalStateException("File should not be missing: " + file);
default:
throw new AssertionError();
}
entries++;
}
return entries;
}
Aggregations