public List collect()

in src/main/java/org/apache/maven/plugins/gpg/FilesCollector.java [71:124]


    public List<Item> collect() throws MojoExecutionException, MojoFailureException {
        List<Item> items = new ArrayList<>();

        if (!"pom".equals(project.getPackaging())) {
            // ----------------------------------------------------------------------------
            // Project artifact
            // ----------------------------------------------------------------------------

            Artifact artifact = RepositoryUtils.toArtifact(project.getArtifact());

            File file = artifact.getFile();

            if (file != null && file.isFile()) {
                items.add(new Item(file, artifact.getExtension()));
            } else if (project.getAttachedArtifacts().isEmpty()) {
                throw new MojoFailureException("The project artifact has not been assembled yet. "
                        + "Please do not invoke this goal before the lifecycle phase \"package\".");
            } else {
                log.debug("Main artifact not assembled, skipping signature generation");
            }
        }

        // ----------------------------------------------------------------------------
        // POM
        // ----------------------------------------------------------------------------

        File pomToSign =
                new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".pom");

        try {
            FileUtils.copyFile(project.getFile(), pomToSign);
        } catch (IOException e) {
            throw new MojoExecutionException("Error copying POM for signing.", e);
        }

        items.add(new Item(pomToSign, "pom"));

        // ----------------------------------------------------------------------------
        // Attached artifacts
        // ----------------------------------------------------------------------------

        for (Artifact artifact : RepositoryUtils.toArtifacts(project.getAttachedArtifacts())) {
            File file = artifact.getFile();

            if (isExcluded(artifact)) {
                log.debug("Skipping generation of signature for excluded " + file);
                continue;
            }

            items.add(new Item(file, artifact.getClassifier(), artifact.getExtension()));
        }

        return items;
    }