boolean copyJarResourcesRecursively()

in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/BuildInstallersMojo.java [340:365]


        boolean copyJarResourcesRecursively(final File destDir, final JarURLConnection jarConnection) throws IOException, MojoExecutionException {

            final JarFile jarFile = jarConnection.getJarFile();

            for (final Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements();) {
                final JarEntry entry = e.nextElement();
                if (entry.getName().startsWith(jarConnection.getEntryName())) {
                    final String filename = StringUtils.removePrefix(entry.getName(), //
                            jarConnection.getEntryName());

                    final File f = new File(destDir, filename);
                    if (!entry.isDirectory()) {
                        final InputStream entryInputStream = jarFile.getInputStream(entry);
                        if (!copyStream(entryInputStream, f)) {
                            return false;
                        }
                        entryInputStream.close();
                    } else {
                        if (!ensureDirectoryExists(f)) {
                            throw new IOException("Could not create directory: " + f.getAbsolutePath());
                        }
                    }
                }
            }
            return true;
        }