/** * Creates and adds a class folder to the class path and imports all files contained in the given * ZIP file. * * @param jproject The parent project * @param containerName * @param sourceAttachPath The source attachment path * @param sourceAttachRoot The source attachment root path * @param zipFile * @return The handle of the created root * @throws IOException * @throws CoreException * @throws InvocationTargetException */ public static IPackageFragmentRoot addClassFolderWithImport( IJavaProject jproject, String containerName, IPath sourceAttachPath, IPath sourceAttachRoot, File zipFile) throws IOException, CoreException, InvocationTargetException { ZipFile file = new ZipFile(zipFile); try { IPackageFragmentRoot root = addClassFolder(jproject, containerName, sourceAttachPath, sourceAttachRoot); importFilesFromZip(file, root.getPath(), null); return root; } finally { file.close(); } }
/** * Adds a source container to a IJavaProject and imports all files contained in the given ZIP * file. * * @param jproject The parent project * @param containerName Name of the source container * @param zipFile Archive to import * @param containerEncoding encoding for the generated source container * @param exclusionFilters Exclusion filters to set * @return The handle to the new source container * @throws InvocationTargetException Creation failed * @throws CoreException Creation failed * @throws IOException Creation failed */ public static IPackageFragmentRoot addSourceContainerWithImport( IJavaProject jproject, String containerName, File zipFile, String containerEncoding, IPath[] exclusionFilters) throws InvocationTargetException, CoreException, IOException { ZipFile file = new ZipFile(zipFile); try { IPackageFragmentRoot root = addSourceContainer(jproject, containerName, exclusionFilters); ((IContainer) root.getCorrespondingResource()).setDefaultCharset(containerEncoding, null); importFilesFromZip(file, root.getPath(), null); return root; } finally { file.close(); } }