public Manifest getManifest()

in src/main/java/org/apache/maven/shared/archiver/MavenArchiver.java [134:185]


    public Manifest getManifest(Session session, Project project, MavenArchiveConfiguration config)
            throws MavenArchiverException {
        boolean hasManifestEntries = !config.isManifestEntriesEmpty();
        Map<String, String> entries = hasManifestEntries ? config.getManifestEntries() : Collections.emptyMap();

        Manifest manifest = getManifest(session, project, config.getManifest(), entries);

        try {
            // any custom manifest entries in the archive configuration manifest?
            if (hasManifestEntries) {

                for (Map.Entry<String, String> entry : entries.entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    Manifest.Attribute attr = manifest.getMainSection().getAttribute(key);
                    if (key.equals(Attributes.Name.CLASS_PATH.toString()) && attr != null) {
                        // Merge the user-supplied Class-Path value with the programmatically
                        // created Class-Path. Note that the user-supplied value goes first
                        // so that resources there will override any in the standard Class-Path.
                        attr.setValue(value + " " + attr.getValue());
                    } else {
                        addManifestAttribute(manifest, key, value);
                    }
                }
            }

            // any custom manifest sections in the archive configuration manifest?
            if (!config.isManifestSectionsEmpty()) {
                for (ManifestSection section : config.getManifestSections()) {
                    Manifest.Section theSection = new Manifest.Section();
                    theSection.setName(section.getName());

                    if (!section.isManifestEntriesEmpty()) {
                        Map<String, String> sectionEntries = section.getManifestEntries();

                        for (Map.Entry<String, String> entry : sectionEntries.entrySet()) {
                            String key = entry.getKey();
                            String value = entry.getValue();
                            Manifest.Attribute attr = new Manifest.Attribute(key, value);
                            theSection.addConfiguredAttribute(attr);
                        }
                    }

                    manifest.addConfiguredSection(theSection);
                }
            }
        } catch (ManifestException e) {
            throw new MavenArchiverException("Unable to create manifest", e);
        }

        return manifest;
    }