private void writeOriginalFile(FileCopyDetails fileDetails) { String path = fileDetails.getRelativePath().getPathString(); try { ZipEntry archiveEntry = new ZipEntry(path); archiveEntry.setTime(fileDetails.getLastModified()); zipOutStr.putNextEntry(archiveEntry); fileDetails.copyTo(zipOutStr); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", path, zipFile), e); } }
public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(filterType); } });
private void visitFile(FileCopyDetails fileDetails) { try { TarEntry archiveEntry = new TarEntry(fileDetails.getRelativePath().getPathString()); archiveEntry.setModTime(getArchiveTimeFor(fileDetails)); archiveEntry.setSize(fileDetails.getSize()); archiveEntry.setMode(UnixStat.FILE_FLAG | fileDetails.getMode()); tarOutStr.putNextEntry(archiveEntry); fileDetails.copyTo(tarOutStr); tarOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to TAR '%s'.", fileDetails, tarFile), e); } }
private void visitFile(FileCopyDetails fileDetails) { try { ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString()); archiveEntry.setTime(getArchiveTimeFor(fileDetails)); archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode()); zipOutStr.putNextEntry(archiveEntry); fileDetails.copyTo(zipOutStr); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e); } }
public void execute(FileCopyDetails fileCopyDetails) { RelativePath path = fileCopyDetails.getRelativePath(); String newName = transformer.transform(path.getLastName()); if (newName != null) { path = path.replaceLastName(newName); fileCopyDetails.setRelativePath(path); } } }
private void visitDir(FileCopyDetails dirDetails) { try { // Trailing slash in name indicates that entry is a directory ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/'); archiveEntry.setTime(dirDetails.getLastModified()); zipOutStr.putNextEntry(archiveEntry); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e); } } }
private void visitDir(FileCopyDetails dirDetails) { try { // Trailing slash in name indicates that entry is a directory ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/'); archiveEntry.setTime(getArchiveTimeFor(dirDetails)); archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode()); zipOutStr.putNextEntry(archiveEntry); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e); } } }
private long getArchiveTimeFor(FileCopyDetails details) { return preserveFileTimestamps ? details.getLastModified() : CONSTANT_TIME_FOR_ZIP_ENTRIES; } }
eachFile(fcd -> fcd.setRelativePath(stripFirstName(fcd.getRelativePath()))); into((Callable) this::getOutputDirectory); // will get lazily resolved
private void visitDir(FileCopyDetails dirDetails) { try { // Trailing slash on name indicates entry is a directory TarEntry archiveEntry = new TarEntry(dirDetails.getRelativePath().getPathString() + '/'); archiveEntry.setModTime(getArchiveTimeFor(dirDetails)); archiveEntry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode()); tarOutStr.putNextEntry(archiveEntry); tarOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to TAR '%s'.", dirDetails, tarFile), e); } } }
private long getArchiveTimeFor(FileCopyDetails details) { return preserveFileTimestamps ? details.getLastModified() : CONSTANT_TIME_FOR_TAR_ENTRIES; } }
private void writeGzippedFile(FileCopyDetails fileDetails) { String path = fileDetails.getRelativePath().getPathString() + ".gz"; try { ZipEntry archiveEntry = new ZipEntry(path); archiveEntry.setTime(fileDetails.getLastModified()); zipOutStr.putNextEntry(archiveEntry); GZIPOutputStream out = new GZIPOutputStream(zipOutStr, true); fileDetails.copyTo(out); out.finish(); out.flush(); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", path, zipFile), e); } }
public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(transformer); } });
@Override public void execute(FileCopyDetails fileCopyDetails) { String dirName = buildCSSTask.getOutputDirName(); dirName = dirName.replace('\\', '/'); if (dirName.charAt(0) != '/') { dirName = '/' + dirName; } if (dirName.charAt(dirName.length() - 1) != '/') { dirName = dirName + '/'; } String path = fileCopyDetails.getPath(); fileCopyDetails.setPath(path.replace(dirName, "/")); }
@Override public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(_fixCrLfArgs, FixCrLfFilter.class); }
@TaskAction public void extractWebjars() { getProject().sync(sync -> { sync.into(outputDirectory); sync.setDuplicatesStrategy(DuplicatesStrategy.WARN); webjars.filter(File::isFile).getFiles().forEach(file -> sync.from(getProject().zipTree(file), jarSpec -> { jarSpec.include("META-INF/resources/webjars/**"); jarSpec.setIncludeEmptyDirs(false); jarSpec.eachFile(fcd -> fcd.setPath(fcd.getPath().replaceFirst("META-INF/resources/webjars/(.*?)/(.*?)/", "$1/"))); }) ); }); } }
public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(properties, filterType); } });