public void unpack()

in src/main/java/org/apache/maven/plugins/dependency/utils/UnpackUtil.java [82:156]


    public void unpack(
            File file,
            String type,
            File location,
            String includes,
            String excludes,
            String encoding,
            boolean ignorePermissions,
            FileMapper[] fileMappers,
            Log logger)
            throws MojoExecutionException {
        try {
            logUnpack(logger, file, location, includes, excludes);

            location.mkdirs();
            if (!location.exists()) {
                throw new MojoExecutionException(
                        "Location to write unpacked files to could not be created: " + location);
            }

            if (file.isDirectory()) {
                // usual case is a future jar packaging, but there are special cases: classifier and other packaging
                throw new MojoExecutionException("Artifact has not been packaged yet. When used on reactor artifact, "
                        + "unpack should be executed after packaging: see MDEP-98.");
            }

            UnArchiver unArchiver;

            try {
                unArchiver = archiverManager.getUnArchiver(type);
                logger.debug("Found unArchiver: " + unArchiver.getClass().getName() + " by type: " + type);
            } catch (NoSuchArchiverException e) {
                unArchiver = archiverManager.getUnArchiver(file);
                logger.debug("Found unArchiver: " + unArchiver.getClass().getName() + " by file extension: " + file);
            }

            if (encoding != null && unArchiver instanceof ZipUnArchiver) {
                ((ZipUnArchiver) unArchiver).setEncoding(encoding);
                logger.info("Unpacks '" + type + "' with encoding '" + encoding + "'.");
            }

            unArchiver.setIgnorePermissions(ignorePermissions);

            unArchiver.setSourceFile(file);

            unArchiver.setDestDirectory(location);

            if ((excludes != null && !excludes.isEmpty()) || (includes != null && !includes.isEmpty())) {
                // Create the selectors that will filter
                // based on include/exclude parameters
                // MDEP-47
                IncludeExcludeFileSelector[] selectors =
                        new IncludeExcludeFileSelector[] {new IncludeExcludeFileSelector()};

                if (excludes != null && !excludes.isEmpty()) {
                    selectors[0].setExcludes(excludes.split(","));
                }

                if (includes != null && !includes.isEmpty()) {
                    selectors[0].setIncludes(includes.split(","));
                }

                unArchiver.setFileSelectors(selectors);
            }

            unArchiver.setFileMappers(fileMappers);

            unArchiver.extract();
        } catch (NoSuchArchiverException e) {
            throw new MojoExecutionException("Unknown archiver type", e);
        } catch (ArchiverException e) {
            throw new MojoExecutionException("Error unpacking file: " + file + " to: " + location, e);
        }
        buildContext.refresh(location);
    }