public File archiveArchetype( File archetypeDirectory, File outputDirectory, String finalName ) throws DependencyResolutionRequiredException, IOException { File jarFile = new File( outputDirectory, finalName + ".jar" ); zip( archetypeDirectory, jarFile ); return jarFile; }
public ArchetypeCatalog getDefaultLocalCatalog() { return getLocalCatalog("${user.home}/.m2/archetype-catalog.xml"); }
public ArchetypeCatalog getRemoteCatalog() { return getRemoteCatalog(Constants.REMOTE_CATALOG); }
public void zip(File sourceDirectory, File archive) throws IOException { if (!archive.getParentFile().exists()) { archive.getParentFile().mkdirs(); } ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(archive)); zos.setLevel(9); zipper(zos, sourceDirectory.getAbsolutePath().length(), sourceDirectory); zos.close(); }
public void updateLocalCatalog(org.apache.maven.archetype.catalog.Archetype archetype) { updateLocalCatalog(archetype, "${user.home}/.m2/archetype-catalog.xml"); }
public void zip( File sourceDirectory, File archive ) throws IOException { if ( !archive.getParentFile().exists() ) { archive.getParentFile().mkdirs(); } ZipOutputStream zos = null; try { zos = new ZipOutputStream( new FileOutputStream( archive ) ); zos.setLevel( 9 ); zipper( zos, sourceDirectory.getAbsolutePath().length(), sourceDirectory ); } finally { IOUtil.close( zos ); } }
private void zipper(ZipOutputStream zos, int offset, File currentSourceDirectory) throws IOException { File[] files = currentSourceDirectory.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { zipper(zos, offset, files[i]); } else { String fileName = files[i].getAbsolutePath().substring(offset + 1); if (File.separatorChar != '/') { fileName = fileName.replace('\\', '/'); } ZipEntry e = new ZipEntry(fileName); zos.putNextEntry(e); FileInputStream is = new FileInputStream(files[i]); byte[] buf = new byte[4096]; int n; while ((n = is.read(buf)) > 0) { zos.write(buf, 0, n); } is.close(); zos.flush(); zos.closeEntry(); } } }
public File archiveArchetype(File archetypeDirectory, File outputDirectory, String finalName) throws DependencyResolutionRequiredException, IOException { File jarFile = new File(outputDirectory, finalName + ".jar"); zip(archetypeDirectory, jarFile); return jarFile; }
zipper( zos, offset, files[i] );