private List getFilters()

in src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java [931:998]


    private List<Filter> getFilters() throws MojoExecutionException {
        List<Filter> filters = new ArrayList<>();
        List<SimpleFilter> simpleFilters = new ArrayList<>();

        if (this.filters != null && this.filters.length > 0) {
            Map<Artifact, ArtifactId> artifacts = new HashMap<>();

            artifacts.put(project.getArtifact(), new ArtifactId(project.getArtifact()));

            for (Artifact artifact : project.getArtifacts()) {
                artifacts.put(artifact, new ArtifactId(artifact));
            }

            for (ArchiveFilter filter : this.filters) {
                ArtifactId pattern = new ArtifactId(filter.getArtifact());

                Set<File> jars = new HashSet<>();

                for (Map.Entry<Artifact, ArtifactId> entry : artifacts.entrySet()) {
                    if (entry.getValue().matches(pattern)) {
                        Artifact artifact = entry.getKey();

                        jars.add(artifact.getFile());

                        if (createSourcesJar) {
                            File file = resolveArtifactForClassifier(artifact, "sources");
                            if (file != null) {
                                jars.add(file);
                            }
                        }

                        if (shadeTestJar) {
                            File file = resolveArtifactForClassifier(artifact, "tests");
                            if (file != null) {
                                jars.add(file);
                            }
                        }
                    }
                }

                if (jars.isEmpty()) {
                    getLog().debug("No artifact matching filter " + filter.getArtifact());

                    continue;
                }

                simpleFilters.add(new SimpleFilter(jars, filter));
            }
        }

        filters.addAll(simpleFilters);

        if (minimizeJar) {
            if (entryPoints == null) {
                entryPoints = new HashSet<>();
            }
            getLog().info("Minimizing jar " + project.getArtifact()
                    + (entryPoints.isEmpty() ? "" : " with entry points"));

            try {
                filters.add(new MinijarFilter(project, getLog(), simpleFilters, entryPoints));
            } catch (IOException e) {
                throw new MojoExecutionException("Failed to analyze class dependencies", e);
            }
        }

        return filters;
    }