protected Collection collectArtifacts()

in src/main/java/org/apache/maven/plugins/gpg/SignDeployedMojo.java [220:254]


    protected Collection<Artifact> collectArtifacts(RepositorySystemSession session, RemoteRepository remoteRepository)
            throws IOException {
        Collection<Artifact> result = null;
        for (ArtifactCollectorSPI artifactCollector : artifactCollectors.values()) {
            result = artifactCollector.collectArtifacts(session, remoteRepository);
            if (result != null) {
                break;
            }
        }
        if (result == null) {
            if (artifacts != null) {
                try {
                    Path path = Paths.get(artifacts);
                    if (Files.isRegularFile(path)) {
                        try (Stream<String> lines = Files.lines(path)) {
                            result = lines.filter(l -> !l.isEmpty() && !l.startsWith("#"))
                                    .map(DefaultArtifact::new)
                                    .collect(Collectors.toSet());
                        }
                    }
                } catch (InvalidPathException e) {
                    // ignore
                }
                if (result == null) {
                    result = Arrays.stream(artifacts.split(","))
                            .map(DefaultArtifact::new)
                            .collect(Collectors.toSet());
                }
            }
        }
        if (result == null) {
            throw new IllegalStateException("No source to collect from (set -Dartifacts=g:a:v... or add collector)");
        }
        return result;
    }