@Override public void open(JarPackageData jarPackage, Shell displayShell, MultiStatus status) throws CoreException { super.open(jarPackage, displayShell, status); fJarPackage= jarPackage; fJarWriter= new JarWriter4(fJarPackage, displayShell); }
@Override public void close() throws CoreException { if (fJarWriter != null) { fJarWriter.close(); } }
@Override public void writeFile(File file, IPath destinationPath) throws CoreException { fJarWriter.write(file, destinationPath); }
private void addFile(File file, IPath path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.toString().replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(file), new byte[4096]); } newEntry.setTime(file.lastModified()); addEntry(newEntry, new FileInputStream(file)); } }
public void writeRsrcUrlClasses() throws IOException { InputStream is= JavaPlugin.getDefault().getBundle().getEntry(JAR_RSRC_LOADER_ZIP).openStream(); ZipInputStream zis= new ZipInputStream(is); ZipEntry zipEntry= zis.getNextEntry(); while (zipEntry != null) { if (!zipEntry.isDirectory()) { String entryName= zipEntry.getName(); byte[] content= FatJarPackagerUtil.readInputStream(zis); getJarWriter().addZipEntryStream(zipEntry, new ByteArrayInputStream(content), entryName); } zipEntry= zis.getNextEntry(); } } }
public void write(File file, IPath destinationPath) throws CoreException { try { addFile(file, destinationPath); } catch (IOException ex) { // Ensure full path is visible String message= null; IPath path= new Path(file.getAbsolutePath()); if (ex.getLocalizedMessage() != null) message= Messages.format(JarPackagerMessages.JarWriter_writeProblemWithMessage, new Object[] { BasicElementLabels.getPathLabel(path, false), ex.getLocalizedMessage() }); else message= Messages.format(JarPackagerMessages.JarWriter_writeProblem, BasicElementLabels.getPathLabel(path, false)); throw JarPackagerUtil.createCoreException(message, ex); } }
private void addFile(String destinationPath, ZipEntry jarEntry, ZipFile zipFile) { // Handle META-INF/MANIFEST.MF if (destinationPath.equalsIgnoreCase("META-INF/MANIFEST.MF") //$NON-NLS-1$ || (isRemoveSigners() && destinationPath.startsWith("META-INF/") && destinationPath.endsWith(".SF"))) { //$NON-NLS-1$//$NON-NLS-2$ return; } try { getJarWriter().addZipEntry(jarEntry, zipFile, destinationPath); } catch (IOException ex) { if (ex instanceof ZipException && ex.getMessage() != null && ex.getMessage().startsWith("duplicate entry:")) {//$NON-NLS-1$ // ignore duplicates in META-INF (*.SF, *.RSA) if (!destinationPath.startsWith("META-INF/")) { //$NON-NLS-1$ addWarning(ex.getMessage(), ex); } } else addWarning(Messages.format(FatJarPackagerMessages.FatJarBuilder_error_readingArchiveFile, new Object[] { BasicElementLabels.getResourceName(zipFile.getName()), ex.getLocalizedMessage() }), ex); } } }
private void addFile(File file, IPath path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.toString().replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(file), new byte[4096]); } newEntry.setTime(file.lastModified()); addEntry(newEntry, new FileInputStream(file)); } }
public void writeRsrcUrlClasses() throws IOException { InputStream is= JavaPlugin.getDefault().getBundle().getEntry(JAR_RSRC_LOADER_ZIP).openStream(); ZipInputStream zis= new ZipInputStream(is); ZipEntry zipEntry= zis.getNextEntry(); while (zipEntry != null) { if (!zipEntry.isDirectory()) { String entryName= zipEntry.getName(); byte[] content= FatJarPackagerUtil.readInputStream(zis); getJarWriter().addZipEntryStream(zipEntry, new ByteArrayInputStream(content), entryName); } zipEntry= zis.getNextEntry(); } } }
public void write(File file, IPath destinationPath) throws CoreException { try { addFile(file, destinationPath); } catch (IOException ex) { // Ensure full path is visible String message= null; IPath path= new Path(file.getAbsolutePath()); if (ex.getLocalizedMessage() != null) message= Messages.format(JarPackagerMessages.JarWriter_writeProblemWithMessage, new Object[] { BasicElementLabels.getPathLabel(path, false), ex.getLocalizedMessage() }); else message= Messages.format(JarPackagerMessages.JarWriter_writeProblem, BasicElementLabels.getPathLabel(path, false)); throw JarPackagerUtil.createCoreException(message, ex); } }
private void addFile(String destinationPath, ZipEntry jarEntry, ZipFile zipFile) { // Handle META-INF/MANIFEST.MF if (destinationPath.equalsIgnoreCase("META-INF/MANIFEST.MF") //$NON-NLS-1$ || (isRemoveSigners() && destinationPath.startsWith("META-INF/") && destinationPath.endsWith(".SF"))) { //$NON-NLS-1$//$NON-NLS-2$ return; } try { getJarWriter().addZipEntry(jarEntry, zipFile, destinationPath); } catch (IOException ex) { if (ex instanceof ZipException && ex.getMessage() != null && ex.getMessage().startsWith("duplicate entry:")) {//$NON-NLS-1$ // ignore duplicates in META-INF (*.SF, *.RSA) if (!destinationPath.startsWith("META-INF/")) { //$NON-NLS-1$ addWarning(ex.getMessage(), ex); } } else addWarning(Messages.format(FatJarPackagerMessages.FatJarBuilder_error_readingArchiveFile, new Object[] { BasicElementLabels.getResourceName(zipFile.getName()), ex.getLocalizedMessage() }), ex); } } }
public void addZipEntry(ZipEntry zipEntry, ZipFile zipFile, String path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(zipEntry.getSize()); newEntry.setCrc(zipEntry.getCrc()); } long lastModified= System.currentTimeMillis(); // Set modification time newEntry.setTime(lastModified); addEntry(newEntry, zipFile.getInputStream(zipEntry)); }
@Override public void writeArchive(ZipFile jarFile, IProgressMonitor progressMonitor) { File jarPathFile= new File(jarFile.getName()); String jarName = jarPathFile.getName(); while (jarNames.contains(jarName)) { jarName= FatJarPackagerUtil.nextNumberedFileName(jarName); } jarNames.add(jarName); JarEntry newEntry = new JarEntry(jarName); newEntry.setMethod(ZipEntry.STORED); byte[] readBuffer= new byte[4096]; try { if (!fJarPackage.isCompressed()) JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(jarPathFile), readBuffer); getJarWriter().addZipEntryStream(newEntry, new FileInputStream(jarPathFile), jarName); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void writeFile(File file, IPath destinationPath) throws CoreException { fJarWriter.write(file, destinationPath); }
@Override public void open(JarPackageData jarPackage, Shell displayShell, MultiStatus status) throws CoreException { super.open(jarPackage, displayShell, status); fJarPackage= jarPackage; fJarWriter= new JarWriter4(fJarPackage, displayShell); }
@Override public void close() throws CoreException { if (fJarWriter != null) { fJarWriter.close(); } }
public void addZipEntry(ZipEntry zipEntry, ZipFile zipFile, String path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(zipEntry.getSize()); newEntry.setCrc(zipEntry.getCrc()); } long lastModified= System.currentTimeMillis(); // Set modification time newEntry.setTime(lastModified); addEntry(newEntry, zipFile.getInputStream(zipEntry)); }
@Override public void writeArchive(ZipFile jarFile, IProgressMonitor progressMonitor) { File jarPathFile= new File(jarFile.getName()); String jarName = jarPathFile.getName(); while (jarNames.contains(jarName)) { jarName= FatJarPackagerUtil.nextNumberedFileName(jarName); } jarNames.add(jarName); JarEntry newEntry = new JarEntry(jarName); newEntry.setMethod(ZipEntry.STORED); byte[] readBuffer= new byte[4096]; try { if (!fJarPackage.isCompressed()) JarPackagerUtil.calculateCrcAndSize(newEntry, new FileInputStream(jarPathFile), readBuffer); getJarWriter().addZipEntryStream(newEntry, new FileInputStream(jarPathFile), jarName); } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void writeFile(IFile resource, IPath destinationPath) throws CoreException { fJarWriter.write(resource, destinationPath); }
public void addZipEntryStream(ZipEntry zipEntry, InputStream is, String path) throws IOException { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(path); JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/')); if (fJarPackage.isCompressed()) newEntry.setMethod(ZipEntry.DEFLATED); // Entry is filled automatically. else { newEntry.setMethod(ZipEntry.STORED); newEntry.setSize(zipEntry.getSize()); newEntry.setCrc(zipEntry.getCrc()); } long lastModified= System.currentTimeMillis(); // Set modification time newEntry.setTime(lastModified); addEntry(newEntry, is); }