@RequestMapping("/starter.zip") @ResponseBody public ResponseEntity<byte[]> springZip(BasicProjectRequest basicRequest) throws IOException { ProjectRequest request = (ProjectRequest) basicRequest; File dir = this.projectGenerator.generateProjectStructure(request); File download = this.projectGenerator.createDistributionFile(dir, ".zip"); String wrapperScript = getWrapperScript(request); new File(dir, wrapperScript).setExecutable(true); Zip zip = new Zip(); zip.setProject(new Project()); zip.setDefaultexcludes(false); ZipFileSet set = new ZipFileSet(); set.setDir(dir); set.setFileMode("755"); set.setIncludes(wrapperScript); set.setDefaultexcludes(false); zip.addFileset(set); set = new ZipFileSet(); set.setDir(dir); set.setIncludes("**,"); set.setExcludes(wrapperScript); set.setDefaultexcludes(false); zip.addFileset(set); zip.setDestFile(download.getCanonicalFile()); zip.execute(); return upload(download, dir, generateFileName(request, "zip"), "application/zip"); }
ZipFileSet zipFileSet = new ZipFileSet(); zipFileSet.setPrefix("WEB-INF/lib"); zipFileSet.setDir(new File(libsToAddDir)); task.addFileset(zipFileSet); task.setUpdate(true);
private void updateSourceWar(File jspCompileDir) { // Finally need to merge the compiled jsps in War warTask = new War(); warTask.setProject(getProject()); warTask.setDestFile(war); warTask.setUpdate(true); ZipFileSet jspFiles = new ZipFileSet(); // The JSPs will be in the a well known location. The // app name from server.xml and the war file name will // be // in the path, the war name minus the .war extension // (if present) will also be used. jspFiles.setDir(jspCompileDir); warTask.addClasses(jspFiles); warTask.setTaskName(getTaskName()); warTask.execute(); }
zip.setDestFile(dest); ZipFileSet fs = new ZipFileSet(); fs.setDir(source); fs.setPrefix(serverName); fs.setProject(project);