@RequestMapping(path = "/starter.tgz", produces = "application/x-compress") @ResponseBody public ResponseEntity<byte[]> springTgz(BasicProjectRequest basicRequest) throws IOException { ProjectRequest request = (ProjectRequest) basicRequest; File dir = this.projectGenerator.generateProjectStructure(request); File download = this.projectGenerator.createDistributionFile(dir, ".tar.gz"); String wrapperScript = getWrapperScript(request); new File(dir, wrapperScript).setExecutable(true); Tar zip = new Tar(); zip.setProject(new Project()); zip.setDefaultexcludes(false); TarFileSet set = zip.createTarFileSet(); set.setDir(dir); set.setFileMode("755"); set.setIncludes(wrapperScript); set.setDefaultexcludes(false); set = zip.createTarFileSet(); set.setDir(dir); set.setIncludes("**,"); set.setExcludes(wrapperScript); set.setDefaultexcludes(false); zip.setDestFile(download.getCanonicalFile()); Tar.TarCompressionMethod method = new Tar.TarCompressionMethod(); method.setValue("gzip"); zip.setCompression(method); zip.execute(); return upload(download, dir, generateFileName(request, "tar.gz"), "application/x-compress"); }
private void bzipTestResults(File dir) { File destFile = new File(dir, "results.tar.bz2"); Tar bzipTask = new Tar(); Tar.TarCompressionMethod bzip2 = new Tar.TarCompressionMethod(); bzip2.setValue("bzip2"); bzipTask.setCompression(bzip2); bzipTask.setProject(new Project()); bzipTask.setDestFile(destFile); FileSet fs = bzipTask.createTarFileSet(); fs.setDir(dir); fs.setIncludes("*.html"); bzipTask.execute(); log.info("bzipped test results: " + destFile.getAbsolutePath()); }
Tar tar = new Tar(); Tar.TarCompressionMethod tarCompressionMethod = new Tar.TarCompressionMethod(); tarCompressionMethod.setValue("gzip"); tar.setCompression(tarCompressionMethod); Tar.TarLongFileMode fileMode = new Tar.TarLongFileMode();
private TarCompressionMethod getCompressionMethod() { TarCompressionMethod method = new TarCompressionMethod(); method.setValue(getCompressionMode()); return method; }
/** * Default constructor */ public TarCompressionMethod() { super(); setValue(NONE); }