/** * Creates and returns a JarWriter for this JAR package. * * @param parent the shell used to display question dialogs, * or <code>null</code> if "false/no/cancel" is the answer * and no dialog should be shown * @return a JarWriter3 * @see JarWriter3 * @throws CoreException if an unexpected exception happens * * @since 3.2 */ public JarWriter3 createJarWriter3(Shell parent) throws CoreException { return new JarWriter3(this, parent); }
/** * Creates the directory entries for the given path and writes it to the current archive. * * @param destinationPath the path to add * * @throws IOException if an I/O error has occurred */ protected void addDirectories(IPath destinationPath) throws IOException { addDirectories(destinationPath.toString()); }
@Override public void close() throws CoreException { if (fJarWriter != null) { fJarWriter.close(); } }
fJarPackage= jarPackage; Assert.isTrue(fJarPackage.isValid(), "The JAR package specification is invalid"); //$NON-NLS-1$ if (!canCreateJar(parent)) throw new OperationCanceledException(); Assert.isTrue(fJarPackage.areDirectoryEntriesIncluded()); final IPath metaPath= new Path(JarPackagerUtil.getMetaEntry()); addDirectories(metaPath); addHistory(fJarPackage, new Path(JarPackagerUtil.getRefactoringsEntry()), new NullProgressMonitor());
/** * Writes the passed resource to the current archive. * * @param resource * the file to be written * @param destinationPath * the path for the file inside the archive * @throws CoreException * to signal any other unusual termination. This can also be * used to return information in the status object. */ public void write(IFile resource, IPath destinationPath) throws CoreException { try { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(resource, destinationPath); addFile(resource, destinationPath); } catch (IOException ex) { // Ensure full path is visible String message= null; if (ex.getLocalizedMessage() != null) message= Messages.format(JarPackagerMessages.JarWriter_writeProblemWithMessage, new Object[] {resource.getFullPath(), ex.getLocalizedMessage()}); else message= Messages.format(JarPackagerMessages.JarWriter_writeProblem, resource.getFullPath()); throw JarPackagerUtil.createCoreException(message, ex); } }
@Override public void writeFile(IFile resource, IPath destinationPath) throws CoreException { fJarWriter.write(resource, destinationPath); }
/** * Closes the archive and does all required cleanup. * * @throws CoreException * to signal any other unusual termination. This can also be * used to return information in the status object. */ public void close() throws CoreException { if (fJarOutputStream != null) try { fJarOutputStream.close(); registerInWorkspaceIfNeeded(); } catch (IOException ex) { throw JarPackagerUtil.createCoreException(ex.getLocalizedMessage(), ex); } }
writeMetaData(data, file, path); } finally { if (output != null) {
addEntry(newEntry, contentStream);
fJarPackage= jarPackage; Assert.isTrue(fJarPackage.isValid(), "The JAR package specification is invalid"); //$NON-NLS-1$ if (!canCreateJar(parent)) throw new OperationCanceledException(); Assert.isTrue(fJarPackage.areDirectoryEntriesIncluded()); final IPath metaPath= new Path(JarPackagerUtil.getMetaEntry()); addDirectories(metaPath); addHistory(fJarPackage, new Path(JarPackagerUtil.getRefactoringsEntry()), new NullProgressMonitor());
/** * Writes the passed resource to the current archive. * * @param resource * the file to be written * @param destinationPath * the path for the file inside the archive * @throws CoreException * to signal any other unusual termination. This can also be * used to return information in the status object. */ public void write(IFile resource, IPath destinationPath) throws CoreException { try { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(resource, destinationPath); addFile(resource, destinationPath); } catch (IOException ex) { // Ensure full path is visible String message= null; if (ex.getLocalizedMessage() != null) message= Messages.format(JarPackagerMessages.JarWriter_writeProblemWithMessage, new Object[] {BasicElementLabels.getPathLabel(resource.getFullPath(), false), ex.getLocalizedMessage()}); else message= Messages.format(JarPackagerMessages.JarWriter_writeProblem, BasicElementLabels.getPathLabel(resource.getFullPath(), false)); throw JarPackagerUtil.createCoreException(message, ex); } }
@Override public void writeFile(IFile resource, IPath destinationPath) throws CoreException { fJarWriter.write(resource, destinationPath); }
/** * Closes the archive and does all required cleanup. * * @throws CoreException * to signal any other unusual termination. This can also be * used to return information in the status object. */ public void close() throws CoreException { if (fJarOutputStream != null) try { fJarOutputStream.close(); registerInWorkspaceIfNeeded(); } catch (IOException ex) { throw JarPackagerUtil.createCoreException(ex.getLocalizedMessage(), ex); } }
writeMetaData(data, file, path); } finally { if (output != null) {
addEntry(newEntry, contentStream);
fJarPackage= jarPackage; Assert.isTrue(fJarPackage.isValid(), "The JAR package specification is invalid"); //$NON-NLS-1$ if (!canCreateJar(parent)) throw new OperationCanceledException(); Assert.isTrue(fJarPackage.areDirectoryEntriesIncluded()); final IPath metaPath= new Path(JarPackagerUtil.getMetaEntry()); addDirectories(metaPath); addHistory(fJarPackage, new Path(JarPackagerUtil.getRefactoringsEntry()), new NullProgressMonitor());
/** * Writes the passed resource to the current archive. * * @param resource * the file to be written * @param destinationPath * the path for the file inside the archive * @throws CoreException * to signal any other unusual termination. This can also be * used to return information in the status object. */ public void write(IFile resource, IPath destinationPath) throws CoreException { try { if (fJarPackage.areDirectoryEntriesIncluded()) addDirectories(resource, destinationPath); addFile(resource, destinationPath); } catch (IOException ex) { // Ensure full path is visible String message= null; if (ex.getLocalizedMessage() != null) message= Messages.format(JarPackagerMessages.JarWriter_writeProblemWithMessage, new Object[] {BasicElementLabels.getPathLabel(resource.getFullPath(), false), ex.getLocalizedMessage()}); else message= Messages.format(JarPackagerMessages.JarWriter_writeProblem, BasicElementLabels.getPathLabel(resource.getFullPath(), false)); throw JarPackagerUtil.createCoreException(message, ex); } }
/** * Creates and returns a JarWriter for this JAR package. * * @param parent the shell used to display question dialogs, * or <code>null</code> if "false/no/cancel" is the answer * and no dialog should be shown * @return a JarWriter3 * @see JarWriter3 * @throws CoreException if an unexpected exception happens * * @since 3.2 * @deprecated use {@link #createPlainJarBuilder()} instead */ @Deprecated public JarWriter3 createJarWriter3(Shell parent) throws CoreException { return new JarWriter3(this, parent); }
private void exportClassFiles(IProgressMonitor progressMonitor, ITypeRoot typeRootElement, IPath destinationPath) { if (fJarPackage.areClassFilesExported()) { try { if (!typeRootElement.exists()) return; // find corresponding file(s) on classpath and export Iterator iter= filesOnClasspath(typeRootElement, destinationPath, progressMonitor); IPath baseDestinationPath= destinationPath.removeLastSegments(1); while (iter.hasNext()) { IFile file= (IFile)iter.next(); IPath classFilePath= baseDestinationPath.append(file.getName()); progressMonitor.subTask(Messages.format(JarPackagerMessages.JarFileExportOperation_exporting, classFilePath.toString())); fJarWriter.write(file, classFilePath); } } catch (CoreException ex) { addToStatus(ex); } } }
@Override public void close() throws CoreException { if (fJarWriter != null) { fJarWriter.close(); } }