/** * Sets base directory for the archive. * * @param baseDir Base archive directory to set. */ @Override public void setBasedir(File baseDir) { super.setBasedir(baseDir); this.baseDir = baseDir; }
Zip zip = new Zip(); zip.setBasedir(new File(this.workdirectory.getAbsolutePath() + FILE_SEPARATOR + JONAS_ROOT_FOLDER)); zip.setDestFile(new File(this.workdirectory.getAbsolutePath() + FILE_SEPARATOR + JONAS_ROOT_ZIP_FILE)); zip.setUpdate(true); zip.setBasedir(new File(this.workdirectory.getAbsolutePath() + FILE_SEPARATOR + JONAS_BASE_FOLDER)); zip.setDestFile(new File(this.workdirectory.getAbsolutePath() + FILE_SEPARATOR + JONAS_BASE_ZIP_FILE)); zip.setUpdate(true);
/** * Copies a jar file from the master to slave. */ private void copyJar(PrintStream log, FilePath dst, Class<?> representative, String seedName) throws IOException, InterruptedException { // in normal execution environment, the master should be loading 'representative' from this jar, so // in that way we can find it. File jar = Which.jarFile(representative); if(jar.isDirectory()) { // but during the development and unit test environment, we may be picking the class up from the classes dir Zip zip = new Zip(); zip.setBasedir(jar); File t = File.createTempFile(seedName, "jar"); t.delete(); zip.setDestFile(t); zip.setProject(new Project()); zip.execute(); jar = t; } new FilePath(jar).copyTo(dst.child(seedName +".jar")); log.println("Copied "+seedName+".jar"); } }
Project p = new Project(); p.init(); Zip zip = new Zip(); zip.setProject(p); zip.setDestFile(zipFile); // a java.io.File for the zip you want to create zip.setBasedir(new File("D:\\reports")); zip.setIncludes("january/**"); zip.perform();
/** * Zip jonas-starter folder to jonas-starter.jar. */ public void zipStarter() { Project p = new Project(); Zip zip = new Zip(); zip.setBasedir(getStarterDefaultLocation()); zip.setDestFile(new File(this.starterJarFileLocation.getAbsolutePath(), this.starterJarFileName)); zip.setUpdate(true); zip.setProject(p); try { zip.execute(); setStarterDefaultLocation(new File(this.starterJarFileLocation.getAbsolutePath(), this.starterJarFileName)); renameStarterJarFile(); this.output.write(this.starterJarFileName + " successfully created !"); this.output.write("Location: " + this.starterDefaultLocation); } catch (Exception e) { this.output.write("Error in packaging jonas-starter : " + e.getMessage()); } }
/** * Copies a jar file from the master to slave. */ static FilePath copyJar(PrintStream log, FilePath dst, Class<?> representative, String seedName) throws IOException, InterruptedException { // in normal execution environment, the master should be loading 'representative' from this jar, so // in that way we can find it. File jar = Which.jarFile(representative); FilePath copiedJar = dst.child(seedName + ".jar"); if (jar.isDirectory()) { // but during the development and unit test environment, we may be picking the class up from the classes dir Zip zip = new Zip(); zip.setBasedir(jar); File t = File.createTempFile(seedName, "jar"); t.delete(); zip.setDestFile(t); zip.setProject(new Project()); zip.execute(); jar = t; } else if (copiedJar.exists() && copiedJar.digest().equals(Util.getDigestOf(jar))) { log.println(seedName + ".jar already up to date"); return copiedJar; } // Theoretically could be a race condition on a multi-executor Windows slave; symptom would be an IOException during the build. // Could perhaps be solved by synchronizing on dst.getChannel() or similar. new FilePath(jar).copyTo(copiedJar); log.println("Copied " + seedName + ".jar"); return copiedJar; }
zip.setBasedir(getJonasRoot()); zip.setDestFile(new File(this.workdirectory, JONAS_ROOT_ZIP_FILE)); zip.setUpdate(true); zip.setBasedir(getJonasBase()); zip.setDestFile(new File(this.workdirectory, JONAS_BASE_ZIP_FILE)); zip.setUpdate(true);