private void processArtifactSelectors()

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


    private void processArtifactSelectors(
            Set<File> artifacts,
            Set<String> artifactIds,
            Set<File> sourceArtifacts,
            Set<File> testArtifacts,
            Set<File> testSourceArtifacts,
            ArtifactSelector artifactSelector)
            throws MojoExecutionException {

        List<String> excludedArtifacts = new ArrayList<>();
        List<String> pomArtifacts = new ArrayList<>();
        List<String> emptySourceArtifacts = new ArrayList<>();
        List<String> emptyTestArtifacts = new ArrayList<>();
        List<String> emptyTestSourceArtifacts = new ArrayList<>();

        ArrayList<Artifact> processedArtifacts = new ArrayList<>();
        if (extraArtifacts != null && !extraArtifacts.isEmpty()) {
            processedArtifacts.addAll(extraArtifacts.stream()
                    .map(org.eclipse.aether.artifact.DefaultArtifact::new)
                    .map(RepositoryUtils::toArtifact)
                    .collect(Collectors.toList()));

            for (Artifact artifact : processedArtifacts) {
                try {
                    org.eclipse.aether.artifact.Artifact resolved =
                            resolveArtifact(RepositoryUtils.toArtifact(artifact));
                    if (resolved.getFile() != null) {
                        artifact.setFile(resolved.getFile());
                    }
                } catch (ArtifactResolutionException e) {
                    throw new MojoExecutionException(
                            "Failed to create shaded artifact: parameter extraArtifacts contains artifact "
                                    + artifact.getId() + " that is not resolvable",
                            e);
                }
            }
        }
        processedArtifacts.addAll(project.getArtifacts());

        for (Artifact artifact : processedArtifacts) {
            if (!artifactSelector.isSelected(artifact)) {
                excludedArtifacts.add(artifact.getId());

                continue;
            }

            if ("pom".equals(artifact.getType())) {
                pomArtifacts.add(artifact.getId());
                continue;
            }

            getLog().debug("Including " + artifact.getId() + " in the shaded jar.");

            artifacts.add(artifact.getFile());
            artifactIds.add(getId(artifact));

            if (createSourcesJar) {
                File file = resolveArtifactForClassifier(artifact, "sources");
                if (file != null) {
                    if (file.length() > 0) {
                        sourceArtifacts.add(file);
                    } else {
                        emptySourceArtifacts.add(artifact.getArtifactId());
                    }
                }
            }

            if (shadeTestJar) {
                File file = resolveArtifactForClassifier(artifact, "tests");
                if (file != null) {
                    if (file.length() > 0) {
                        testArtifacts.add(file);
                    } else {
                        emptyTestArtifacts.add(artifact.getId());
                    }
                }
            }

            if (createTestSourcesJar) {
                File file = resolveArtifactForClassifier(artifact, "test-sources");
                if (file != null) {
                    testSourceArtifacts.add(file);
                } else {
                    emptyTestSourceArtifacts.add(artifact.getId());
                }
            }
        }

        for (String artifactId : excludedArtifacts) {
            getLog().debug("Excluding " + artifactId + " from the shaded jar.");
        }
        for (String artifactId : pomArtifacts) {
            getLog().debug("Skipping pom dependency " + artifactId + " in the shaded jar.");
        }
        for (String artifactId : emptySourceArtifacts) {
            getLog().warn("Skipping empty source jar " + artifactId + ".");
        }
        for (String artifactId : emptyTestArtifacts) {
            getLog().warn("Skipping empty test jar " + artifactId + ".");
        }
        for (String artifactId : emptyTestSourceArtifacts) {
            getLog().warn("Skipping empty test source jar " + artifactId + ".");
        }
    }